본문 바로가기

Server Story..../Linux

ext4 로 파티션 구성하기.

1. 시스템 기본정보 확인
[root@test /]# uname -a
Linux test 2.6.18-238.el5PAE #1 SMP Thu Jan 13 17:10:20 EST 2011 i686 i686 i386 GNU/Linux
[root@test /]#
[root@test /]#

2. 디스크의 파티션 확인
[root@test /]#
[root@test /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             9.7G  1.2G  8.1G  13% /
/dev/sda3             201G  188M  190G   1% /home
tmpfs                  16G     0   16G   0% /dev/shm
[root@test /]#

3. 물리적인 디스크 확인
    ; 추가 장착된 /dev/sdb 를 ext4 파일시스템을 만들겠습니다.
[root@test /]#
[root@test /]# fdisk -l

Disk /dev/sda: 249.5 GB, 249510756352 bytes
255 heads, 63 sectors/track, 30334 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1305    10482381   83  Linux
/dev/sda2            1306        3366    16554982+  82  Linux swap / Solaris
/dev/sda3            3367       30334   216620460   83  Linux

Disk /dev/sdb: 249.5 GB, 249510756352 bytes
255 heads, 63 sectors/track, 30334 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
[root@test /]#
[root@test /]#

4. 새로운 파티션 생성
[root@test /]#
[root@test /]# fdisk /dev/sdb

The number of cylinders for this disk is set to 30334.
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): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help):
Command (m for help):
Command (m for help):
Command (m for help): p

Disk /dev/sdb: 249.5 GB, 249510756352 bytes
255 heads, 63 sectors/track, 30334 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help):
Command (m for help):
Command (m for help):
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-30334, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-30334, default 30334):
Using default value 30334

Command (m for help):
Command (m for help):
Command (m for help):
Command (m for help): p

Disk /dev/sdb: 249.5 GB, 249510756352 bytes
255 heads, 63 sectors/track, 30334 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1        1       30334   243657823+  83  Linux

Command (m for help):
Command (m for help):
Command (m for help):
Command (m for help): w        <- 저장은 꼭! 합시다^^
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@test /]#

5. 생성된 파티션 확인
[root@test /]#
[root@test /]# fdisk -l

Disk /dev/sda: 249.5 GB, 249510756352 bytes
255 heads, 63 sectors/track, 30334 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1305    10482381   83  Linux
/dev/sda2            1306        3366    16554982+  82  Linux swap / Solaris
/dev/sda3            3367       30334   216620460   83  Linux

Disk /dev/sdb: 249.5 GB, 249510756352 bytes
255 heads, 63 sectors/track, 30334 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       30334   243657823+  83  Linux
[root@test /]#
[root@test /]#
[root@test /]#

6. ext4 파일시스템을 사용할 수 있게 e4fsprogs 를 설치
[root@test /]#
[root@test /]# yum install e4fsprogs
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.daum.net
 * extras: centos.mirror.cdnetworks.com
 * updates: ftp.riken.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package e4fsprogs.i386 0:1.41.12-2.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
 Package                        Arch                      Version                            Repository                 Size
=============================================================================================================================
Installing:
 e4fsprogs                      i386                      1.41.12-2.el5                      base                      1.1 M

Transaction Summary
=============================================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
http://ftp.daum.net/centos/5.6/os/i386/CentOS/e4fsprogs-1.41.12-2.el5.i386.rpm: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
e4fsprogs-1.41.12-2.el5.i386.rpm                                                                      | 1.1 MB     00:01   
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : e4fsprogs                                                                                             1/1

Installed:
  e4fsprogs.i386 0:1.41.12-2.el5                                                                                           

Complete!
[root@test /]#

<e4fsprogs 관련 파일 참고>

[root@test ~]# rpm -ql e4fsprogs
/etc/mke4fs.conf
/sbin/debuge4fs
/sbin/dumpe4fs
/sbin/e4fsck
/sbin/e4image
/sbin/e4label
/sbin/e4undo
/sbin/finde4fs
/sbin/fsck.ext4
/sbin/fsck.ext4dev
/sbin/mke4fs
/sbin/mkfs.ext4
/sbin/mkfs.ext4dev
/sbin/resize4fs
/sbin/tune4fs
/usr/share/doc/e4fsprogs-1.41.12
/usr/share/doc/e4fsprogs-1.41.12/README
/usr/share/doc/e4fsprogs-1.41.12/RELEASE-NOTES
/usr/share/locale/ca/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/cs/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/de/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/es/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/fr/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/id/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/it/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/nl/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/pl/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/sv/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/tr/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/vi/LC_MESSAGES/e4fsprogs.mo
/usr/share/locale/zh_CN/LC_MESSAGES/e4fsprogs.mo
/usr/share/man/man5/e4fsck.conf.5.gz
/usr/share/man/man5/mke4fs.conf.5.gz
/usr/share/man/man8/debuge4fs.8.gz
/usr/share/man/man8/dumpe4fs.8.gz
/usr/share/man/man8/e4fsck.8.gz
/usr/share/man/man8/e4image.8.gz
/usr/share/man/man8/e4label.8.gz
/usr/share/man/man8/e4undo.8.gz
/usr/share/man/man8/fsck.ext4.8.gz
/usr/share/man/man8/fsck.ext4dev.8.gz
/usr/share/man/man8/mke4fs.8.gz
/usr/share/man/man8/mkfs.ext4.8.gz
/usr/share/man/man8/mkfs.ext4dev.8.gz
/usr/share/man/man8/resize4fs.8.gz
/usr/share/man/man8/tune4fs.8.gz

[root@test /]#
[root@test /]#

7. 새로 만든 파티션을 ext4 파일시스템으로 생성
[root@test /]#
[root@test /]# mkfs.ext4 /dev/sdb1
mke4fs 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
15228928 inodes, 60914455 blocks
3045722 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1859 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, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune4fs -c or -i to override.
[root@test /]#

8. 새로운 디렉토리(/data)에 마운트
[root@test /]#
[root@test /]# mkdir /data
[root@test /]#
[root@test /]# mount /dev/sdb1 /data
[root@test /]#
[root@test /]#
[root@test /]# df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda1     ext3    9.7G  1.2G  8.1G  13% /
/dev/sda3     ext3    201G  188M  190G   1% /home
tmpfs        tmpfs     16G     0   16G   0% /dev/shm
/dev/sdb1     ext4    229G  188M  217G   1% /data
[root@test /]#

9. ext4는 e2label이 적용되지 않는다.
[root@test /]#
[root@test /]# e4label
Usage: e4label device [newlabel]
[root@test /]#
[root@test /]# e4label /dev/sdb1 /data
[root@test /]#
[root@test /]#
[root@test /]# e4label /dev/sdb1
/data
[root@test /]#
[root@test /]#


10. 자동으로 /data 파티션을 마운트하도록 설정
[root@test /]# vi /etc/fstab

LABEL=/1                /                       ext3    defaults        1 1
LABEL=/home             /home                   ext3    defaults        1 2
LABEL=/data             /data                   ext4    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-sda2         swap                    swap    defaults        0 0
~
~
:wq!
[root@test /]# reboot