티스토리 뷰

Linux

리눅스 UUID 로 디스크 추가 / 삭제

초보의 CHOMAN 2017.02.21 19:30


리눅스 UUID 로 디스크 추가 / 삭제




UUID는 센트오에스6에서 처름본 개념같은데 장치들을 구분하기 위한 고유한 값이라고 생각된다.


디스크를 예를 들면 /dev/sda , /dev/sdb 이런식으로 구분되는데 하드디스크가 1개 사용하는 경우는 상관없지만


2개 이상 사용하는 경우 헷갈리거나 꼬여버리는 경우 정리가 힘들다고 한다.





UUID 생성하기


: 그냥 단순히 UUID 하나를 생성해주는 명령어 인듯 하다.

 

[root@iwinvhelper-303 ~]# uuidgen

ccc08845-72c9-4850-ace5-1447b6dcb169





UUID 보기


 

[root@iwinvhelper-303 ~]# blkid

/dev/vda1: UUID="ad11bafe-de2c-4d3f-be13-51dd0ef0d819" TYPE="ext4"





UUID로 마운트 하기


 

mount UUID="aab38e85-1ff1-4403-bd3d-b57fb42f671c" /mnt





UUID로 언마운트 하기


 

umount UUID="aab38e85-1ff1-4403-bd3d-b57fb42f671c"





UUID 변경하기 (UUID로 사용할 값을 uuidgen 명령어로 하나 생성한다)


 

tune2fs -U eafec66f-d257-4605-a5ed-cf36fbb195c4 /dev/sdb1





디스크를 하나 추가한 후 파티션 잡기랑 포맷까지 하기


 

[root@iwinvhelper-303 ~]# fdisk -l


Disk /dev/vda: 26.8 GB, 26843545600 bytes

139 heads, 8 sectors/track, 47148 cylinders

Units = cylinders of 1112 * 512 = 569344 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000594e0


   Device Boot      Start         End      Blocks   Id  System

/dev/vda1               2       47149    26213376   83  Linux


Disk /dev/vdb: 10.7 GB, 10737418240 bytes

16 heads, 63 sectors/track, 20805 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000




[root@iwinvhelper-303 ~]# fdisk /dev/vdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xed87bffb.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.


Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').


Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-20805, default 1): (엔터)

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-20805, default 20805): (엔터)

Using default value 20805


Command (m for help): wq

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.




[root@iwinvhelper-303 ~]# mkfs.ext4 /dev/vdb1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

655360 inodes, 2621422 blocks

131071 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2684354560

80 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632


Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 28 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.




[root@iwinvhelper-303 ~]# blkid

/dev/vda1: UUID="ad11bafe-de2c-4d3f-be13-51dd0ef0d819" TYPE="ext4"

/dev/vdb1: UUID="dc9dce12-d89c-40a4-8261-8bd2c0ed7bc7" TYPE="ext4"





/etc/fstab 라인 추가


 

UUID=ad11bafe-de2c-4d3f-be13-51dd0ef0d819 /                       ext4    defaults        1 1

UUID=dc9dce12-d89c-40a4-8261-8bd2c0ed7bc7 /mnt                 ext4,nofail    defaults        0 1

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0





/etc/rc.d/rc.local 라인추가 (fstab 에 넣는것이 정석이고 이 방법으로 하는 사람도 있는듯 하다)



mount UUID="dc9dce12-d89c-40a4-8261-8bd2c0ed7bc7" /mnt

 




어쨋든 파티션은 잡힌다.



[root@iwinvhelper-303 ~]# df -Th

Filesystem     Type   Size  Used Avail Use% Mounted on

/dev/vda1      ext4    25G  687M   23G   3% /

tmpfs          tmpfs  246M     0  246M   0% /dev/shm

/dev/vdb1      ext4   9.8G   23M  9.2G   1% /mnt

 




UUID 가 겹치는 경우


 

[root@iwinvhelper-303 ~]# blkid

/dev/vda1: UUID="ad11bafe-de2c-4d3f-be13-51dd0ef0d819" TYPE="ext4"

/dev/vdb1: UUID="dc9dce12-d89c-40a4-8261-8bd2c0ed7bc7" TYPE="ext4"

/dev/vdc1: UUID="dc9dce12-d89c-40a4-8261-8bd2c0ed7bc7" TYPE="ext4"

/dev/vdd1: UUID="dc9dce12-d89c-40a4-8261-8bd2c0ed7bc7" TYPE="ext4"


[root@iwinvhelper-303 ~]# uuidgen

d1a3cf37-a838-4cbb-a4b6-895c540f421c


[root@iwinvhelper-303 ~]# tune2fs -U d1a3cf37-a838-4cbb-a4b6-895c540f421c /dev/vdc1

tune2fs 1.41.12 (17-May-2010)


[root@iwinvhelper-303 ~]# uuidgen

d73a2cf2-2488-42d1-b737-86cfa5559702


[root@iwinvhelper-303 ~]# tune2fs -U d73a2cf2-2488-42d1-b737-86cfa5559702 /dev/vdd1

tune2fs 1.41.12 (17-May-2010)


[root@iwinvhelper-303 ~]# blkid

/dev/vda1: UUID="ad11bafe-de2c-4d3f-be13-51dd0ef0d819" TYPE="ext4"

/dev/vdb1: UUID="dc9dce12-d89c-40a4-8261-8bd2c0ed7bc7" TYPE="ext4"

/dev/vdc1: UUID="d1a3cf37-a838-4cbb-a4b6-895c540f421c" TYPE="ext4"

/dev/vdd1: UUID="d73a2cf2-2488-42d1-b737-86cfa5559702" TYPE="ext4"

[root@iwinvhelper-303 ~]#




드라이브를 포맷하면 UUID는 변경된다.



[root@iwinvhelper-833 ~]# blkid

/dev/vda1: UUID="ad11bafe-de2c-4d3f-be13-51dd0ef0d819" TYPE="ext4"

/dev/vdb1: UUID="109a4789-4111-4cb6-9dc4-3bb9e8fd85a6" TYPE="ext4"

/dev/vdc1: UUID="906672d4-2765-4dde-a66d-7f40aea5bc89" TYPE="ext4"

/dev/vdd1: UUID="29a387ab-6536-4574-a8b4-8035f9c195b7" TYPE="ext4"


[root@iwinvhelper-833 ~]# mkfs.ext4 /dev/vdd1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

1966080 inodes, 7864282 blocks

393214 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

240 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000


Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 27 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.


[root@iwinvhelper-833 ~]# blkid

/dev/vda1: UUID="ad11bafe-de2c-4d3f-be13-51dd0ef0d819" TYPE="ext4"

/dev/vdb1: UUID="109a4789-4111-4cb6-9dc4-3bb9e8fd85a6" TYPE="ext4"

/dev/vdc1: UUID="906672d4-2765-4dde-a66d-7f40aea5bc89" TYPE="ext4"

/dev/vdd1: UUID="41c01ef7-eb16-42cd-b1c1-d0b63e0d8638" TYPE="ext4"




'Linux' 카테고리의 다른 글

mod_rewrite  (0) 2017.09.11
mod_ssl 설치  (0) 2017.09.06
리눅스 UUID 로 디스크 추가 / 삭제  (0) 2017.02.21
MongoDB Driver for PHP  (0) 2017.02.02
LSYNCD  (0) 2016.12.22
MRTG 송 수신 그래프 바꾸기  (0) 2016.09.29
댓글
댓글쓰기 폼