Feeds:
Posts
Comments

Archive for the ‘Filesystems & Partitioning’ Category

If you’ve attached an external hard drive for backing up your files, or created a new partition for storage, only to find you don’t have the permissions to use it, you’d be understandably frustrated. But it’s actually quite easy to remedy by simply running a command in the terminal in the form of:

sudo chown -R username:username /partition/mount-point

Note that the above isn’t the actual command you’ll be using, as you’ll need to replace each instance of username with your actual username, and also determine your mount-point, which is not the device name (eg: /dev/sdb1).

To find the mount-point, run mount in the terminal, and locate the line that corresponds to the drive or partition in question. If you have never named (or set the label for) it, it will probably look something like:

/dev/sdb1 on /media/bf9a2c45-491a-4778-9d76-47832fe38820

If you have set the label with something descriptive, it should like similar to:

/dev/sdb1 on /media/1Tb Pocket Drive

As you can see, your mount-point will look something like /media/bf9a2c45-491a-4778-9d76-47832fe38820 or /media/1Tb Pocket Drive, so all you need to do now is run a command like one of the following, replacing the relevant info with what is appropriate to you:

sudo chown -R billgates:billgates /media/bf9a2c45-491a-4778-9d76-47832fe38820

sudo chown -R billgates:billgates '/media/1Tb Pocket Drive'

Note that if your custom label contains spaces (e.g. 1Tb Pocket Drive) , you will need to enclose the entire mount-point path in single quotes, but won’t need them if it’s a single word or multiple words joined by hyphens or underscores.

That’s it – you should now be able to do whatever you want with the drive or partition in question, as you’re now the owner.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

ption]

Read Full Post »

If you’ve attached an external hard drive to your system, then decided to use your partitioner to format it to EXT4 for greater efficiency (or just to match your Ubuntu system), you may have been shocked to find that your empty drive seemed to be missing a few gigabytes when mounted afterwards. And this has nothing to do with the good old binary (base-8) vs decimal (base-10) situation which would see your “750Gb” drive be more like 700Gb (in Windows and earlier versions of Ubuntu – now Mac OS X and Ubuntu have followed hardware manufacturers and use decimal, so that’s more like 738Gb).

This is because Ubuntu (and other Linux distributions) reserve typically around 5% of the space for the root user and system services, so should you run out of hard drive space, the administrator can still log in, and system services continue to run.

However, this is only really needed for your Ubuntu partition, so if you have an external EXT4 drive, or have an EXT4 partition on your internal drive (other than the one your system is on), you are needlessly wasting space (40Gb of the drive in the example). But you can free up that disk space quite easily, without having to re-partition the drive or anything. All it takes is a couple of commands pasted into the terminal.

In the following example, an external hard-drive will have the reserve set to 0 (zero), since this is what most people will need this for. First, we have to determine the device name, as using its mounted name – /media/700Gb Ext4 – won’t suffice. To do so, enter the following into the terminal:

mount|grep ^'/dev'

Look for the line containing your device:

/dev/sdc1 on /media/700Gb Ext4 type ext4 (rw,nosuid,nodev,uhelper=udisks)

… and you can see what it is named (/dev/sdc1 in this case). To free up reserved space, enter the following (replacing /dev/sdc1 with whatever the appropriate device name is, if need be – just make sure you don’t do it to your main drive!):

sudo tune2fs -m 0 /dev/sdc1

You should then be presented with the following message:

Setting reserved blocks percentage to 0% (0 blocks)

To confirm all has gone well, you can right-click an empty area of the folder window for the device and choose Properties, then compare the free space from before and after, or run the following command (once again replacing the device name with the correct one in your case):

sudo tune2fs -l /dev/sdc1 | grep 'Reserved block count'

You should be greeted with the following:

Reserved block count: 0

That’s it – you now have all of your drive to use.

ΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘΘ

Note: if you receive the following error message:

tune2fs: Bad magic number in super-block while trying to open /dev/sdb1
Couldn’t find valid filesystem superblock.

… then the filesystem likely isn’t EXT4 – chances are the drive is actually formatted as NTFS or FAT for use on Windows systems (which would be the case if you’ve bought an external drive, and never did anything other than copy files to it). You would have needed to partition/format the drive to EXT4, so if you didn’t, then you actually don’t need this guide.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

Ubuntu is pretty awesome when it comes to automounting your drives and USB devices; in my experience, it is miles ahead of Windows, and it keeps getting better with each release. But for a greater level of control, you can’t beat the old-fashioned way: mounting your drives via fstab at boot.

While Ubuntu now mounts drives and partitions in folders with names based on the labels, which includes spaces in the names, fstab is a tad more touchy when it comes to this. If you try mounting a drive in fstab to a mount-point with a path name like /media/Windows XP, the mounting will fail because of the space. Usual methods to get around this, like close the path off with / (ie: /media/Windows XP/) or put it in quotes (ie: ‘/media/Windows XP’ or “/media/Windows XP”), will fail – but there is a solution other than replacing spaces with hypens or underscores.

Simply replace any spaces with \040, so your line in fstab should look something like:

UUID=1D666EVIL6661D /media/Windows\040XP

The drive will mount in the appropriate folder from then onwards (ie: /media/Windows XP), and there’s no need to reboot if you’re urgently trying to access a drive – simply open a terminal and run sudo mount -a to mount all devices in fstab.

°ºÒθÓº°¤°ºÒθÓº°¤°ºÒθÓº°

Just in case you are unfamiliar with fstab, the way you edit it is sudo gedit /etc/fstab. However, if you needed that bit of info, chances are you really shouldn’t be doing so, unless you’ve first read a little of the abundant info available out there on the subject of fstab and mounting drives in Ubuntu (and other Linux distros). The last thing you would want to do is render your system unbootable because you made an error in editing fstab. While this guide is just for how to deal with spaces in paths, still exercise caution if this is all new to you.

°ºÒθÓº°¤°ºÒθÓº°¤°ºÒθÓº°

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

Please note that this is for the “legacy” version of GRUB still widely in use, not the next-generation GRUB 2. If unsure, check out this guide on how to find out which version of GRUB you are using.

↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔

You can quite simply change GRUB‘s preference for Ubuntu being the default operating system (the one it boots to after the countdown has finished) to that of whichever was used last. It will then boot to that when you press Enter or the countdown finishes. Simply open menu.lst for editing as superuser by pasting the following into a terminal:

sudo gedit /boot/grub/menu.lst

and when you see right near the top:

default 0

simply edit it to this:

default saved

Close and save menu.lst and GRUB will automatically boot the last used OS from then onwards. Note that you will still be able to choose other OSes from the boot menu, and that whenever you boot to another, it will become the new default (until you boot another).

↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔

Related Guides:

Make GRUB (Legacy) Boot Into Your Windows System by Default Instead of Ubuntu

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

Please note that this is for the “legacy” version of GRUB still widely in use, not the next-generation GRUB 2. If unsure, check out this guide on how to find out which version of GRUB you are using.

↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔

You can make GRUB boot to an operating system other than Ubuntu, like Windows, by simply editing a bit of text. Open menu.lst for editing as superuser by pasting the following into a terminal:

sudo gedit /boot/grub/menu.lst

and near the top you should see:

default         0

You will need to change the “default” value from “0” (zero) to the number of the Windows entry, which should be near the bottom of the file and look like:

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
title        Windows XP Professional x64 Edition
root        (hd0,0)
savedefault
makeactive
chainloader    +1

Noting that the default entry (Ubuntu) is “0not “1”, simply count the entries at the bottom of menu.lst, and deduct 1 from the value of the Windows drive/partition.

In other words, if your GRUB menu has the four basic options (Ubuntu, Ubuntu Recovery Mode, Memtest+, and Windows), then your Windows drive is the fourth option, so the “default” value should be “3”. Obviously, if your boot menu has some earlier kernels still listed, and altogether there are 8 entries with Windows as the last, then the value would be “7“. As I said, simply count the entries at the bottom of menu.lst (they should all look similar to the Windows one) and deduct one from it (assuming Windows is the last entry, of course).

Close and save menu.lst and GRUB will automatically boot Windows from then onwards. You can of course still choose another OS like Ubuntu at the boot menu before the countdown finishes.

↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔

Related Guides:

Make GRUB (Legacy) Automatically Boot to the Last Used Operating System

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

Please note that this is for the next-generation GRUB 2, not the “legacy” version of GRUB still widely in use. If unsure, check out this guide on how to find out which version of GRUB you are using. For the legacy GRUB version of this guide, click here.

↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔

GRUB 2 has a different system for naming drives than you’re used to in Linux, and you will need to understand this before proceeding with commands or customisisation that requires this specific information. Both the drive and the partition are numbers in GRUB 2, with the drive starting from 0 (zero) and the partition starting with 1 (this is unlike legacy GRUB where both start with zero).

This is different from the Linux convention of naming a drive a letter, and its partitions as numbers, starting with a and 1 respectively (eg: “a” in sda1 meaning first drive, with the “1” meaning the first partition on that drive). Also note that the drive and partition are separated with a , (comma) in the designations GRUB 2 uses.

So therefore the first partition on the first hard drive (sda1 or hda1 in Linux) is hd0,1 in GRUB 2. Similarly, your second hard drive (sdb or hdb) would actually be hd1, and if you were talking about the 7th partition on your 3rd drive (sdc7 or hdc7) it would be hd2,7.

↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔↔

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

For an introduction to drives, partitions and folders in Ubuntu, check out Differences Between Hard Drives & Media Storage Devices in Ubuntu & Windows.

°ºÒθÓº°¤°ºÒθÓº°¤°ºÒθÓº°

The most visual and informative way to get info about your drives and media storage devices, like the path names and filesystems, is to install GParted. That is the same partition editor on the Ubuntu Live CD, and you can install it with sudo apt-get install gparted in the terminal. It will end up in System > Administration, and will either be called Partition Editor, GParted or Gnome Partition Editor.

To change devices, choose another from the dropdown menu in the top right. You can then right-click the partitions and choose Information to get more info.

Another way is to enter sudo fdisk -l in a terminal. It will give you info like so:

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2101e331
Device        Boot   Start      End       Blocks                Id      System
/dev/sda1    *             1     45762   367583233+     7     HPFS/NTFS
/dev/sda2            45763   90564   359872065        83    Linux
/dev/sda3            90565   91201    5116702+          5     Extended
/dev/sda5            90565   91201    5116671            82    Linux swap / Solaris

You can also have a look at everything that’s mounted via gedit /etc/mtab (or cat /etc/mtab if you want the output displayed in the terminal). It will give you something similar to:

/dev/sda2 / ext3 rw,relatime,errors=remount-ro 0 0
proc /proc proc rw 0 0
none /sys sysfs rw,noexec,nosuid,nodev 0 0
none /sys/fs/fuse/connections fusectl rw 0 0
none /sys/kernel/debug debugfs rw 0 0
none /sys/kernel/security securityfs rw 0 0
udev /dev tmpfs rw,mode=0755 0 0
none /dev/pts devpts rw,noexec,nosuid,gid=5,mode=0620 0 0
none /dev/shm tmpfs rw,nosuid,nodev 0 0
none /var/run tmpfs rw,nosuid,mode=0755 0 0
none /var/lock tmpfs rw,noexec,nosuid,nodev 0 0
none /lib/init/rw tmpfs rw,nosuid,mode=0755 0 0
/dev/sda1 /media/Windows-XP-x64 fuseblk rw,nosuid,nodev,allow_other,blksize=4096 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,noexec,nosuid,nodev 0 0

Or you can use sudo blkid (or sudo blkid -c /dev/null) if you just want your drives and partitions listed:

/dev/sda1: UUID=”1D3688CD689CA81D” LABEL=”Windows Drive” TYPE=”ntfs”
/dev/sda2: UUID=”daf56d80-15b5-4314-9672-fd91d12a3bd6″ SEC_TYPE=”ext2″ TYPE=”ext3″
/dev/sda5: UUID=”241939b6-9c32-4cb8-b644-0455c4a5460f” TYPE=”swap”

If you’re just after the unique UUID of a partition, you can also use ls -l /dev/disk/by-uuid:

total 0
lrwxrwxrwx 1 root root 10 2009-12-18 11:10 1D3688CD689CA81D -> ../../sda1
lrwxrwxrwx 1 root root 10 2009-12-18 11:10 241939b6-9c32-4cb8-b644-0455c4a5460f -> ../../sda5
lrwxrwxrwx 1 root root 10 2009-12-18 11:10 daf56d80-15b5-4314-9672-fd91d12a3bd6 -> ../../sda2

You can also find out mount points and drive/partition usage info with df -h:

Filesystem Size Used Avail Use% Mounted on
/dev/sda2 338G 309G 12G 97% /
udev 2.0G 400K 2.0G 1% /dev
none 2.0G 1.7M 2.0G 1% /dev/shm
none 2.0G 216K 2.0G 1% /var/run
none 2.0G 0 2.0G 0% /var/lock
none 2.0G 0 2.0G 0% /lib/init/rw
/dev/sda1 351G 343G 8.4G 98% /media/Windows-XP-x64

Or if you want device paths, mount points and options, especially if you just want to find the device name and mount point of your CD/DVD drive, you can use mount|grep ^'/dev':

/dev/sda2 on / type ext3 (rw,relatime,errors=remount-ro)
/dev/sda1 on /media/Windows-XP-x64 type fuseblk (rw,nosuid,nodev,allow_other,blksize=4096)
/dev/sr0 on /media/cdrom0 type iso9660 (ro,nosuid,nodev,user=ozzman)

As you can see, there are many ways to get technical info about your devices and partitions in Ubuntu. If you’d like to see what files and folders are taking up the most space, check out Filelight for disk usage analysis.

°ºÒθÓº°¤°ºÒθÓº°¤°ºÒθÓº°

How to Find the Block Device File Name of a Disc Drive

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

Here’s some basic info for those wanting to make the move to Ubuntu or another Linux distro. Once you get your head around the folder structure differences to what you’re used to in Windows, you’ll see it’s all quite easy. Basically, you just need to get familiar with some basic concepts like “mount points” and “privileges” (or “permissions”), and remember that while paths (or addresses) in Windows contain \ (backslashes), in Linux it is like the internet, so / (slashes) are used.

Mount Points

Hard drives are not represented as “C:” and “D:” like in Windows, as they are actually accessed from folders serving as “mount points”. So, in effect, other drives, including your DVD drive, are seen as folders in your Ubuntu system, not as separate drives. While the root of a CD or DVD in Windows would be represented as D:\, in Ubuntu and other Linux distros, it would be something like /media/cdrom0 (mount points will vary, but generally found in either /mnt or /media, depending on your distro or Ubuntu version).

The User Folder

In Windows, they’ve increasingly made it difficult to locate your files without using their shortcuts. Back in Windows 95, most of your stuff could be found in C:\My Documents, but by XP it had changed to C:\Documents and Settings\YourName\My Documents. With Vista it changed yet again, this time to C:\Users\YourName\Documents, and will no doubt keep users guessing with each upgrade.

In Ubuntu and most Linux distros, you can always count that every file you own is located in a folder within /home. All other users of the computer will also have their own subfolder within it, and only the owner of each can view and edit files therein. Your documents will be in /home/yourusername/Documents, pictures in /home/yourusername/Pictures, videos in /home/yourusername/Videos, music in /home/yourusername/Music, and so on.

Also, most programs will store their configuration files in hidden subfolders of your user folder. While some settings files will occasionally be in system folders, generally they’ll be in folders like /.mozilla-thunderbird (the . before marks it as a hidden folder, which you won’t see in Nautilus – the default file manager – unless you enable the displaying of hidden files and folders).

System Folders & Permissions

The root of your Ubuntu drive or partition is /, and most of the subfolders belong to the system, or root. In fact, besides the /home and /tmp folders, the rest is controlled by root, so you do not have permission to edit, move, create or delete files in those folders. For that, you need to either log in as root (not recommended), or become the super-user to achieve your goals.

Most people don’t need to go poking in the guts of the system, and as for tweaking programs by manually editing config files, as I mentioned most programs keep all that in your user folder, so you can edit and delete those without need for root privileges.

Filesystems

You’ll see that while Windows does not even recognise a Linux or Mac OS partition, in Ubuntu you can not only access your Windows and Mac drives (and other Linux partitions), but easily write to them as well. This means that if you have a Windows installation, you can access files from that drive while in Ubuntu, and even edit and save them back there. So you can get to all your pictures, etc, without having to reboot, and many file-types will open in compatible programs in Ubuntu (eg: .doc files will open fine in OpenOffice.org Writer).

Devices

Ubuntu is much better with the array of different media storage devices out there than its counterpart. For example, while Windows can handle most devices connected via USB, most versions cannot recognise a drive has been connected via eSATA. Trying to find a way to get eSATA support in XP proved a long and unrewarding process (ie: a big waste of time), while that support is just built into Ubuntu.

Basically anything that can be connected to a computer and has some kind of storage capacity can be accessed in Ubuntu. Don’t be surprised if some devices that need drivers and software in Windows are mounted in Ubuntu without need for anything.

And if you’ve had USB sticks suddenly lose most of their capacity in Windows, and formatting them there did nothing (or actually made it worse), try wiping them in Ubuntu, as I’ve fixed a couple that way!

Drive/Partition Paths

If you’ve ever fiddled with the Windows boot menu or looked at partition information for some reason, you would know that the paths or addresses are actually quite long and complicated compared to the C: you see in My Computer.

In Linux, they’re short and pretty straight forward, which you can see if you open Gnome Partition Editor (sudo apt-get install gparted if you haven’t already got it). Your drives will have names like sda or hda (depending on hardware and Ubuntu version), and the “a” represents the first drive (or Primary Master, if you have older IDE drives). Therefore, your second drive would be sdb/hdb, and other drives would follow in alphabetical order.

Similarly, the partitions start with “1“, so the first partition on the first drive would be /dev/sda1, while the fifth partition on the third drive would be /dev/sdc5, and so on.

For more information on working with devices and partitions in Ubuntu, like finding out UUIDs via the terminal, through to a great graphical disk usage analysis program you can use, check out this page.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »

If your system is slowly grinding to a halt, and multitasking is a nightmare, you may need to check your swap is in use. If you’re experiencing non-stop, furious hard drive activity resulting from even the most simplest tasks (like clicking another tab in your browser, or even something basic like minimising an app), with things you’ve initiated taking 2 minutes or more to appear, then open a terminal and enter top.

You’ll see “Swap” near the beginning, and if the total is 0k (that’s zero kilobytes), then that means your swap has been deactivated for some reason. To enable it again, start the Partition Editor (found in System > Administration; if it isn’t installed, enter sudo apt-get install gparted in a terminal to do so).

Locate linux-swap, right-click it, and choose Swapon. Your swap partition should now be in use, but if you have further hassles, it might pay to reformat (or even delete) the swap with GParted (ie: Partition Editor). To format it again, just right-click the swap and choose Format > linux-swap.

In case the swap appears on (even if not working), you will need to Swapoff to get the Format options. Similarly, if you decide to delete the swap and start again, you might need to turn it off first so the Delete option is available. The swap can then be recreated with the unallocated space it left when deleted, which you would then format as linux-swap.

☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻

Did this information make your day? Did it rescue you from hours of headache? Then please consider making a donation via PayPal, to buy me a donut, beer, or some fish’n’chips for my time and effort! Many thanks!

Buy Ubuntu Genius a Beer to say Thanks!

Read Full Post »