9
2011
Ubuntu automatically mount partition at startup
Check your /etc/fstab file. It should look similar to this :
# /etc/fstab: static file system information. # # Use 'blkid -o value -s UUID' to print the universally unique identifier # for a device; this may be used with UUID= as a more robust way to name # devices that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda5 during installation UUID=9de0aab4-e64c-49c8-af55-cc7375a97dd6 / ext4 errors=remount-ro 0 1 # swap was on /dev/sda6 during installation UUID=31a6807b-3b3e-4f9d-95c2-ead64d0c7009 none swap sw 0 0
Now if a partition is to be mounted at startup , a line for that partition has to be added to this fstab file.
Command to get a list of all partitions :
sudo fdisk -l
Typical output :
Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000ef50d Device Boot Start End Blocks Id System /dev/sda1 * 1 9138 73400953+ 7 HPFS/NTFS /dev/sda2 9139 60801 414982985+ f W95 Ext'd (LBA) /dev/sda5 9139 22192 104856192 83 Linux /dev/sda6 22193 22323 1052226 82 Linux swap / Solaris /dev/sda7 22324 35377 104856223+ 83 Linux /dev/sda8 44942 60801 127395418+ 83 Linux
Command to get the UUID of partitions :
sudo blkid
Typical output :
/dev/sda1: UUID="2A64794864791831" TYPE="ntfs" /dev/sda5: UUID="9de0aab4-e64c-49c8-af55-cc7375a97dd6" TYPE="ext4" /dev/sda6: UUID="31a6807b-3b3e-4f9d-95c2-ead64d0c7009" TYPE="swap" /dev/sda7: UUID="eba07f1f-b287-456a-b3d6-1c40d7b28a60" TYPE="ext4" /dev/sda8: UUID="475abb5b-471f-4a6f-a589-782f3afc427f" TYPE="ext4"
Get the UUID of the partitions that you want to mount at startup.
Add lines to fstab file like this :
# /etc/fstab: static file system information. # # Use 'blkid -o value -s UUID' to print the universally unique identifier # for a device; this may be used with UUID= as a more robust way to name # devices that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda5 during installation UUID=9de0aab4-e64c-49c8-af55-cc7375a97dd6 / ext4 errors=remount-ro 0 1 # swap was on /dev/sda6 during installation UUID=31a6807b-3b3e-4f9d-95c2-ead64d0c7009 none swap sw 0 0 # 100GB /dev/sda7 UUID=eba07f1f-b287-456a-b3d6-1c40d7b28a60 /media/eba07f1f-b287-456a-b3d6-1c40d7b28a60 ext4 errors=remount-ro,auto,exec,rw,user 0 0 # 121GB /dev/sda8 UUID=475abb5b-471f-4a6f-a589-782f3afc427f /media/475abb5b-471f-4a6f-a589-782f3afc427f ext4 errors=remount-ro,auto,exec,rw,user 0 0
For example take the line :
UUID=eba07f1f-b287-456a-b3d6-1c40d7b28a60 /media/eba07f1f-b287-456a-b3d6-1c40d7b28a60 ext4 errors=remount-ro,auto,exec,rw,user 0 0
First part is the UUID , which is fetched from the command blkid.
Next is the path where the drive should be mounted. So first the directory /media/eba07f1f-b287-456a-b3d6-1c40d7b28a60 should be created
Next the file system type , here its ext4
Then comes the options : errors=remount-ro,auto,exec,rw,user
remount-ro means remount partitions incase of read errors.
auto – Automatically mount partitions at startup
exec – Give users permission to execute files on this partition
rw – Give read write permission
user – Allow all non-root users to mount this partition
Save the fstab file and next time your restart Ubuntu , the partitions should be already mounted.
Reference :
1. http://www.tuxfiles.org/linuxhelp/fstab.html
Popularity: 5% [?]
Related Posts
Subscribe
Recent Posts
- Login into phpmyadmin without username and password
- 10+ tips to localise your php application
- 40+ Techniques to enhance your php code – Part 3
- 40+ Techniques to enhance your php code – Part 2
- 40+ Techniques to enhance your php code – Part 1
- CSSDeck – Collection of Pure CSS Creations
- Execute shell commands in PHP
- Php get list of locales installed on system
- Sound cracking in Ubuntu 11.10
- PHP script to perform IP whois
An article by





good explanation
thanks! Pretty useful!