리눅스에서 파티션 추가하는 방법
- Operating System
- 2010. 3. 4.
아래는 일단 하드디스크에 공간이 남아있다는 가정하에...
약 250기가의 하드에 파티션을 주고 그 파티션에 레이블을 opt를 주고....
부팅 시 /opt 에 자동으로 마운트되게 설정한 것을 나타낸 것입니다.
물론 아래 방식이 정답은 아닙니다.
방법은 많이 있겠죠..
[root@vash ~]# fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 12761 102398310 83 Linux
/dev/sda3 12762 12892 1052257+ 82 Linux swap / Solaris
여기서 보면 하드디스크에 여유가 있다는 것을 알 수 있습니다.
root@vash ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 19457.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First cylinder (12893-19457, default 12893):
Using default value 12893
Last cylinder or +size or +sizeM or +sizeK (12893-19457, default 19457):
Using default value 19457
Command (m for help): p
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 12761 102398310 83 Linux
/dev/sda3 12762 12892 1052257+ 82 Linux swap / Solaris
/dev/sda4 12893 19457 52733362+ 5 Extended
Command (m for help): n
First cylinder (12893-19457, default 12893):
Using default value 12893
Last cylinder or +size or +sizeM or +sizeK (12893-19457, default 19457): +256M
Command (m for help): p
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 12761 102398310 83 Linux
/dev/sda3 12762 12892 1052257+ 82 Linux swap / Solaris
/dev/sda4 12893 19457 52733362+ 5 Extended
/dev/sda5 12893 12924 257008+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 장치나 ìžì›ì´ ë™ìž‘ 중.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@vash ~]# fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 12761 102398310 83 Linux
/dev/sda3 12762 12892 1052257+ 82 Linux swap / Solaris
/dev/sda4 12893 19457 52733362+ 5 Extended
/dev/sda5 12893 12924 257008+ 83 Linux
[root@vash ~]# cat /proc/partitions
major minor #blocks name
8 0 156290904 sda
8 1 104391 sda1
8 2 102398310 sda2
8 3 1052257 sda3
[root@vash ~]# partprobe
[root@vash ~]# cat /proc/partitions
major minor #blocks name
8 0 156290904 sda
8 1 104391 sda1
8 2 102398310 sda2
8 3 1052257 sda3
8 4 0 sda4
8 5 257008 sda5
[root@vash ~]# mke2fs -j /dev/sda5
1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
64256 inodes, 257008 blocks
12850 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
32 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@vash ~]# e2label /dev/sda5 opt
[root@vash ~]# blkid | grep /dev/sda5
/dev/sda5: LABEL="opt" UUID="a3585b0c-791b-4301-b51f-fc24f82c6c36" SEC_TYPE="ext2" TYPE="ext3"
[root@vash ~]#
[root@vash ~]# vi /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot1 /boot ext3 defaults 1 2
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
LABEL=SWAP-sda3 swap swap defaults 0 0
LABEL=opt /opt ext3 defaults 0 0
[root@vash ~]#
[root@vash ~]# mount -a
[root@vash ~]# mount | grep "opt"
/dev/sda5 on /opt type ext3 (rw)
[root@vash ~]# [root@vash ~]#