What is UUID used in fstab
UUID –Universally
Unique Identifier/labels
The UUID is useful for identifying hard drives in a Linux
system when other factors used to locate them might change.
To find the UUIDs of all hard
drives (block devices) connected to a running Linux system, open a terminal
and enter sudo blkid at the command prompt. You should see something
like this:
#blkid
/dev/sda1:
UUID="2e2be99d-5a55-4da1-8665-219a405a8f97" TYPE="ext4"
/dev/sda5:
UUID="c2f99f78-bbc9-410a-bf72-186620a8e051" TYPE="swap"
/dev/sdb1: LABEL="new"
UUID="ac3ed2c8-91f1-4d31-a601-28db9a36f53a" TYPE="ext4"
/dev/sdc1: LABEL="porta"
UUID="F1A5-B5DE" TYPE="vfat"
Here, we see four storage devices
and their UUIDs.
|
#ls -la /dev/disk/by-uuid
total 0 drwxr-xr-x. 2 root root 160 Mar 25 00:24 . drwxr-xr-x. 5 root root 100 Mar 25 00:24 .. lrwxrwxrwx. 1 root root 10 Mar 25 00:24 0982ce66-537a-497b-baaf-99136594f3e8 -> ../../sdb1 lrwxrwxrwx. 1 root root 9 Mar 25 00:24 2014-12-02-19-30-23-00 -> ../../sr0 lrwxrwxrwx. 1 root root 10 Mar 25 00:24 5afc1b25-e6cd-45b2-ad20-69f0fed323b9 -> ../../dm-1 lrwxrwxrwx. 1 root root 10 Mar 25 00:24 8f0652a8-d79b-453f-aa2d-0ff0b5d0ae7b -> ../../dm-0 lrwxrwxrwx. 1 root root 10 Mar 25 00:24 94e15e98-1cff-49a9-b76a-a8f3a948e2ea -> ../../dm-2 lrwxrwxrwx. 1 root root 10 Mar 25 00:24 ae55a647-3c57-4ab5-9651-1389703fe6fe -> ../../sda1The UUID is required to permanently mount specific disk drives in /etc/fstab. |
dump2fs
command.But the output of the command will be too long, so use pipe less to
see UUID entry of the partition.
|
#tune2fsHow do I change the UUID?This isn’t hard at all.First find the device pathYou can find the device path using the following command:
Secondly, generate a UUIDThis is simple, the following command will output a UUID like below:
Finally apply the new UUID to the partitionThis is also another command, tune2fs, which will apply our new UUID to our device path:
Linux tune2fs command examplesThe tune2fs utility displays and modifies filesystem parameters on ext2,ext3,and ext4 filesystems. This utility can also setup journaling on an ext2 filesystem, turning it into ext3 filesystem.Below is the examples show you how to use tune2fs to display, modify, and change an ext2 filesystem to ext3 Assume the filesystem has been created on /dev/md1, detail in Ext2, Ext3, and Ext4 filesystems creation on linux Display a filesystem parameters#tune2fs -l /dev/md1 tune2fs 1.41.12 (17-May-2010) Filesystem volume name: <none> Last mounted on: <not available> Filesystem UUID: 957e1766-4723-420e-b942-a5dafe67c661 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file Filesystem flags: signed_directory_hash Default mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 30539776 Block count: 61048976 Reserved block count: 3052448 Free blocks: 19734533 Free inodes: 30508949 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 1009 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 16384 Inode blocks per group: 512 Filesystem created: Tue Sep 27 11:09:10 2011 Last mount time: Fri Aug 21 23:28:40 2015 Last write time: Fri Aug 21 23:33:36 2015 Mount count: 1 Maximum mount count: 32 Last checked: Thu Aug 20 23:19:10 2015 Check interval: 15552000 (6 months) Next check after: Tue Feb 16 22:19:10 2016 Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128 Journal inode: 8 Default directory hash: tea Directory Hash Seed: 0aa9310b-d299-4d55-a83b-e4eca6c0a6f2 Journal backup: inode blocks Modify filesystem parametersAlmost all of the parameters in previous example output can be set by tune2fs, here I jus show few of popular ones as examples, once you know how this utility works, it's easy for other options.Set volume label for a filesystemThe option -L volume-label is to set the volume label of the filesystem/dev/md1 has no volume label in previous output, now set it to data #tune2fs -L data /dev/md1 tune2fs 1.41.12 (17-May-2010) #tune2fs -l /dev/md1 | grep volume Filesystem volume name: data Change an ext2 filesystem to an ext3 filesystemTo change an ext2 filesystem to an ext3 filesystem, you must put a journal on the filesystem, and the kernel must support ext3 filesystems.Use the option -j to set up a journal on an unmounted filesystem: #tune2fs -j /dev/md2Also change the entry in the fstab to reflect its new type. To change an ext3 filesystem to an ext2 filesystem#tune2fs -O ^has_journal /dev/md2 |
Comments
Post a Comment