Tag: Linux

Properly Cleaning Up /boot Partition

This is a follow-up post to a post I made earlier today: Cleaning Up /boot Partition.

I won’t say that the steps in that post aren’t going to help clear up space, but it certainly didn’t do the trick for me. I still had a piled up /boot partition loaded with the kernel images. I can’t explain why, but completely removing them via Synaptic apparently didn’t completely remove them. So, it appears this method is more effective.

Search for installed packages named linux-image* to see the kernels on the machine:

dpkg -l linux-image*

Like before, you can find the current kernel using this command:

uname -r

I recommend keeping the current and its previous kernel, but that choice is yours. Either way, you do not want to remove the current kernel! Using the same example from the previous post, I’ll change the step to remove the same kernel images but using this method.

sudo apt-get remove linux-image-{34,35,36,37,39,40,43,44}-generic

Then, remove dependencies.

sudo apt-get autoremove

 

Cleaning Up /boot Partition

It’s very easy to lose track of how many times the Linux kernel is updated on your system, and, depending on the amount of space allotted to the /boot partition, you’re likely to come across an error stating that there isn’t enough space to provide updates at some point. You may be confused if you see this message, especially since it isn’t always clear where the lack of space is in the message – and you’ll easily tell yourself that there’s no way your root partition doesn’t have the 100MB of space to perform the update. Instead, it’s the boot partition that is lacking the available space.

Why? Because every time the Linux kernel is updated, the previous kernel is kept on the system as well. You might think it pointless, but it’s actually rather nice – especially if a kernel update creates an issue with something you have installed on the system. You can easily boot into a previous kernel in that situation. The problem is that there is no limit to how many kernels are stored, and so after about ten kernel updates, you’re likely going to be out of space – especially with the default 500MB partition allotment that Ubuntu and its derivatives tend to stick with.

The easiest way, in my opinion, to remove these unnecessary kernel images off of the boot partition to provide space for future updates is using Synaptic Package Manger. Some explanations state using the command line to remove the packages, but the UI of Synaptic works great for this.

The first thing I’d advise to do is look at the images stored on the boot partition. You can do that by entering this into your console:

ls /boot/

You’ll see a lot of different files listed, but the most important part of each filename is the version number. Despite the variances in the list of files (abi, config, System, etc.), they should all share the same version numbers in that part of their filenames. The thing I recommend doing is removing all but the last two, which should be the current kernel and the previous one before it. You can check which kernel the system is running with this command:

uname -r

In my situation, I had the following kernels residing on my system:

3.13.0-34-generic
3.13.0-35-generic
3.13.0-36-generic
3.13.0-37-generic
3.13.0-39-generic
3.13.0-40-generic
3.13.0-43-generic
3.13.0-44-generic
3.13.0-45-generic
3.13.0-46-generic

So, I’m removing kernels 3.13.0-34 through 3.13.0-44. After opening Synaptic Package Manager, first click on Installed in the left-hand column to filter out all uninstalled packages. Then, search for the first part of the version numbers for the kernels. eg.: 3.13.

Select each package title linux-headers-x.xx that fits within the kernel versions we’re removing, and after you’ve highlighted all of them click the green box next to it and select Mark for Complete Removal. You’ll notice that all of the linux-image-x.xx packages have also turned red and are selected for removal. Simply hit Apply at the top and confirm with the popup for the packages to be removed and Synaptic will do the rest. It should take only a few seconds, but less than a minute in any case.

While you’re in Synaptic, you can also remove any residual configurations by selecting Not installed (residual config) in the left-pane and removing any packages listed there as well. This will clear up any configurations left by packages that have been removed from the system – freeing up wasted space.

Installing Linux via Bootable USB

Most of my Linux experience has been with Ubuntu. If not Ubuntu, then a relative flavor with Linux Mint and some slight tinkering with elementaryOS. The great thing about these three is that you can easily create a bootable media for either running a live desktop to test or to install thanks to the Startup Disk Creator application that ships with Ubuntu and Linux Mint both (and likely eOS also, but I didn’t check).

If you want to create a bootable media for another distribution, you’re out of luck with Startup Disk Creator. Even Debian distributions, which Ubuntu is derived from and actually show up in the pane listing ISO source images to use in Startup Disk Creator, won’t complete write to the USB drive without spitting out an error right before it would normally queue for password to write the boot record onto the media.

You’ll get a few different opinions on how to create a bootable media when searching online, some of which suggest installing and using additional packages such as UNetBootin or USB Creator. If you’re not comfortable with using terminal, or aren’t familiar enough with mounted drives and devices to make sure you don’t commit an act that will cause you to potentially lose vital data on your computer, then perhaps those are the better options.

For me, I hate installing any applications or packages that I don’t need. Since Ubuntu, and I wager most Linux distributions, ship with dd I prefer to use that. What’s better is its use is fairly straight-forward on top of it. You can get a few ideas of what dd can be used for by viewing its Wikipedia page. It appears to be a relatively easy option for backing up sensitive data, such as the MBR on a drive.

But anyway. If you’re looking to create a bootable media for a non-buntu distro, you can do so with dd with the following command:

sudo dd if=image.is of=/dev/sd?

If you read up on dd at the Wikipedia page, you’d have seen that there is also an argument you can pass: bs. By default, bs, which defines the block size for reading and writing in dd, is 512 bytes. Some suggestions that I’ve seen online recommend defining the block size to be larger. Larger block size would lean one to believe means less cycles when writing. So, you may want to bump that up to something larger, though staying within appropriate boundaries. Examples online of using dd to create writable USB drives often include a block size of 1MB. So, you could include that in the command:

sudo dd if=media.is of=/dev/sd? bs=1M

You must also make sure the media you’re writing to isn’t mounted before using dd to write to it:

sudo umount /dev/sd?

So, for example, if you’re USB drive was mounted as device sdc and your Linux distro image was named Linux-LiveUSB.iso (and we’re assuming you’ve navigated terminal to be in the same directory as the ISO image to avoid needing to include the path), you would issue the following to write it to the USB drive:

sudo umount /dev/sdc
sudo dd if=Linux-LiveUSB.iso of=/dev/sdc bs=1M

A brief summary of the commands are

  • if: Input File. This is the location and file that is being read from.
  • of: Output File. This is the location and/or file that is being written to.
  • bs: Block Size. This is the size, in bytes, that each data block is being read and written at. The default is 512, so leaving this undefined will have dd read and write data blocks at 512 bytes.

Lastly, I would say to only use this method if you need to create a bootable USB drive, and there are no other pre-installed software to get the job done. For example, why use this over Startup Disk Creator if you’re in a *buntu OS and need to create a bootable *buntu USB drive? There is no reason to. If you’re writing to a CD/DVD, then I would think the included disk burning software on your system would work just fine. If not, then dd should work fine for that as well. Just use the device name of the disk burner when designating the output file in the command. If the idea of manipulating data via terminal scares you, then I’d say better safe than sorry, and just look around for a fitting application with an easy UI.

Netflix Official Linux Support

There’s finally an officially supported way to watch Netflix on Linux without jumping hurdles through various methods that try to work around their Silverlight requirement.

Perhaps they’re copying the same method that allows Chromebook users to stream Netflix, but it requires the Chrome browser in Linux to do it. Before I did this, I attempted to install and configure Pipelight to see if I could stream a show in Firefox, and I was met with the incompatibility page. So, I removed Pipelight and installed Chrome. Went to Netflix, logged in and the show I tried to view opened up without a hitch – lacking any additional packages installed besides Chrome itself.

Though I prefer Firefox to Chrome, I’ll happily boot up Chrome if only to watch Netflix. It sure beats the uncertain methods of trying to either emulate or immitate Silverlight, which has been the popular tactic for some time now.

You can grab the Chrome package to install directly from your machine by going to its download page, or you can install it from terminal using APT by adding Google’s repositories:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable

 

The Linux Hurdle

Okay. After talking with a co-worker yesterday about why he should install Linux on his somewhat-antiquated Vista-ran laptop, I ran into road blocks. He’s pretty reluctant to heed my suggestion and even dip his toes, let alone jump in head-first.

I’ve tried to make points of why I like Linux better than Windows. However, the truth is that I don’t consider Linux a replacement for Windows. It’s like driving vehicles. I drive my smaller compact car almost everyday, because it’s more convenient for typical day travelling and it gets better gas-mileage. So, why do I keep my pick-up truck? It’s a gas guzzler, and depending on the time and place it can be impossible to find a parking spot. Still, if I have to haul something or traverse tougher terrain that requires a vehicle with more clearance or four-wheel drive, my truck is there to save the day. In this case, my compact car is Linux and my truck is Windows. Linux will almost always get the job done, typically faster and with less hassle, while Windows is there to provide any crucial services that Linux just can’t do.

Being that my co-worker’s laptop hard-drive is fairly full, he’s running Vista and he says he has never de-fragged his hard-drive, I’d bet that I can boot up, check my emails, pay a couple of bills, shut down and boot back up to my work space in Linux before he even reaches his desktop for the first time in Vista. And my Linux setup has been installed for nearly two years now. Though, I’d say a fresh install of Linux wouldn’t do it any better. The same can’t be said for Windows.

But like I said, I’m not saying throw Windows out the window. I’m just saying make use of the tools available to you. What’s the point of booting into Windows to do generic tasks that end up taking far longer to complete than they necessarily have to? After all, the less you use Windows, the longer it takes to slow down. Of course, good practices and regular maintenance can help keep Windows running as good as possible. But when you can minimize the amount of work necessary in those respects as well, it makes no sense not to at least dip your toes in. And the sales pitch is spot on: Linux is free, it is generally designed to boot alongside of Windows and it is fairly easy to remove it and revert back to just having Windows if you decide you don’t wish to keep it.

I hope my co-worker comes to the decision of giving Linux a shot. After all, I never used Linux once until two years ago when I decided that testing out a freely available OS seemed like a fun endeavour. It ended up causing me to change up my routine permanently.

XAMPP with Ubuntu

If you want a nicely compiled web server to use for testing, nothing beats XAMPP. And if you use Windows, it’s even nicer with XAMPP Lite. It’s so convenient, you can even run the server from a USB thumb drive.

However, I’ve learned recently that Linux doesn’t have quite as many convenient options. If you wish to set up a web server on Linux, there are countless tutorials across the net on doing it. For me, I just wanted something that I could run and test some things when I needed to without having to upload it to a production web server. Not to mention, it’s faster when everything is on a local machine. I was hoping that a XAMPP Lite setup had been released for Linux, but I was unfortunately wrong. Unlike Windows, Linux would require XAMPP to be installed in the /opt/ directory, which is owned by root. This means my system user wouldn’t be able to access the directory and directly alter files/folders, at least not without steps that extend beyond the directions given on the XAMPP website.

First off, I followed the directions for installing XAMPP exactly as described on the website. At first glance, everything looks fine. However, once I tried to access FTP using the default nobody user, I realized something was wrong. It gave me a 550 permissions error. Initial searching online seemed to indicate that the error wasn’t typical with others, so I figured something must have gone wrong with the installation. I had also installed the most recent beta version. I decided to uninstall, download the latest non-beta version and install it. Everything, again, went as expected with no errors. Again, I logged in via FTP and found that I could not create directories or alter files due to insufficient permissions. Doing a little more troubleshooting, I found that the lampp/htdocs folder was actually solely owned by root, instead of being owned by the user nobody and the root group. The nobody user had no ownership of the directory or its contained files/folders and therefore no permissions to affect it. I logged into root via terminal and changed ownership of the lampp/htdocs to nobody and from there everything worked fine accessing the directory via FTP.

A different approach would have been to change ownership of the directory to my own system user, this way I could directly alter the files/folders through nautilus without even having to run the proFTPD server. Since I am using the web server for testing locally anyway, this would have been the way to go.

For reference, here are the terminal commands used.

For listing ownership of files within a directory:

ls -l <path>

If you are already within the directory for which you want to list ownership of subsequent files and folders, you can leave the <path> value empty.

For changing ownership of the htdocs directory:

chown -R <username>:<usergroup> /opt/lampp/htdocs

Using your username for both the <username>  and <usergroup>  values will be fine.

The reason I recommend XAMPP over other Linux web server packages for using as a test server is that it is the easiest to uninstall that I have seen. Deleting the /opt/lampp directory is all that has to be done for complete removal.