본문 바로가기

Job Notes/Linux & Android

[Linux filesystem] ex3 파일 시스템 설정

[ 목  차 ]

1. 구성된 파일 시스템 정보 확인
2. 1024MB Disk Size의 ext3 파일 시스템 추가 
3. 변경된 파일 시스템 적용을 위한 partprobe 명령어 실행
4. 파일 시스템 정보 확인
5. /dev/hda7 디스크의 ext3  파일 시스템으로 생성
6. /dev/hda7 디스크의 mount 위치 디렉토리 생성
7. /dev/hda7 디스크를 /ext3_data 디렉토리로 Mount
8. /ext3_data 디렉토리의 파일 생성 테스트
9. /ext3_data 디렉토리의 Unmount10. Rebooting 시 /ext3_data 디렉토리 Static Mount
11. mount 명령어를 이용한 /etc/fstab 설정 파일의 파일 시스템 Mount
12. Troubleshtooing 

1. 구성된 파일 시스템 정보 확인 

[command]# fdisk -l

Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End       Blocks           Id  System
/dev/hda1   *           1          16         128488+      83  Linux
/dev/hda2              17          2627     20972857+  83  Linux
/dev/hda3            2628        2888     2096482+    83  Linux
/dev/hda4            2889        4865     15880252+   f    W95 Ext'd (LBA)
/dev/hda5            2889        3149     2096451      83  Linux
/dev/hda6            3150        3410    2096451      82  Linux swap

 

 

Disk /dev/hdb: 20.5 GB, 20520493056 bytes
255 heads, 63 sectors/track, 2494 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End       Blocks         Id  System
/dev/hdb1   *           1          16        128488+     83  Linux
/dev/hdb2              17          2494    19904535   83  Linux

 

Disk /dev/hdd: 30.6 GB, 30614814720 bytes
255 heads, 63 sectors/track, 3722 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks           Id  System
/dev/hdd1   *           1          3722    29896933+  83  Linux

 

[command]# cat /proc/partitions
major minor  #blocks       name

   3        0      39082680   hda
   3        1      128488       hda1
   3        2      20972857   hda2
   3        3      2096482     hda3
   3        4      1                 hda4
   3        5      2096451     hda5
   3        6      2096451     hda6


   3       64     20039544   hdb
   3       65     128488       hdb1
   3       66     19904535   hdb2


  22      64     29897280   hdd
  22      65     29896933   hdd1

   

2. 1024MB Disk Size의 ext3 파일 시스템 추가 

[command]# fdisk /dev/hda

The number of cylinders for this disk is set to 4865.
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): p

Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End       Blocks           Id   System
/dev/hda1   *           1          16         128488+      83   Linux
/dev/hda2              17          2627     20972857+  83   Linux
/dev/hda3            2628        2888     2096482+    83   Linux
/dev/hda4            2889        4865     15880252+   f     W95 Ext'd (LBA)
/dev/hda5            2889        3149     2096451      83   Linux
/dev/hda6            3150        3410     2096451      82   Linux swap

 

Command (m for help): n
First cylinder (3411-4865, default 3411): <Enter>
Using default value 3411
Last cylinder or +size or +sizeM or +sizeK (3411-4865, default 4865): +1024M

 

Command (m for help): p

Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End       Blocks           Id   System
/dev/hda1   *           1          16         128488+      83   Linux
/dev/hda2              17          2627     20972857+  83   Linux
/dev/hda3            2628        2888     2096482+    83   Linux
/dev/hda4            2889        4865     15880252+   f     W95 Ext'd (LBA)
/dev/hda5            2889        3149     2096451      83   Linux
/dev/hda6            3150        3410     2096451      82   Linux swap
/dev/hda7            3411        3535     1004031      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: Device or resourc
e busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

 

[command]# cat /proc/partitions
major minor  #blocks       name

   3        0      39082680   hda
   3        1      128488       hda1
   3        2      20972857   hda2
   3        3      2096482     hda3
   3        4      1                 hda4
   3        5      2096451     hda5
   3        6      2096451     hda6


   3       64     20039544   hdb
   3       65     128488       hdb1
   3       66     19904535   hdb2


  22      64     29897280   hdd
  22      65     29896933   hdd1

 

  

3. 변경된 파일 시스템 적용을 위한 partprobe 명령어 실행

[command]# partprobe

4. 파일 시스템 정보 확인

[command]# fdisk -l

Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End       Blocks           Id  System
/dev/hda1   *           1          16         128488+      83  Linux
/dev/hda2              17          2627     20972857+  83  Linux
/dev/hda3            2628        2888     2096482+    83  Linux
/dev/hda4            2889        4865     15880252+   f    W95 Ext'd (LBA)
/dev/hda5            2889        3149     2096451      83  Linux
/dev/hda6            3150        3410     2096451      82  Linux swap

/dev/hda7          3411       3535    1004031    83  Linux

 

Disk /dev/hdb: 20.5 GB, 20520493056 bytes
255 heads, 63 sectors/track, 2494 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End       Blocks         Id  System
/dev/hdb1   *           1          16        128488+     83  Linux
/dev/hdb2              17          2494    19904535   83  Linux

 

Disk /dev/hdd: 30.6 GB, 30614814720 bytes
255 heads, 63 sectors/track, 3722 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks           Id  System
/dev/hdd1   *           1          3722    29896933+  83  Linux

 

[command]# cat /proc/partitions 
major minor  #blocks  name
   3        0      39082680   hda
   3        1      128488       hda1
   3        2      20972857   hda2
   3        3      2096482     hda3
   3        4      1                 hda4
   3        5      2096451     hda5
   3        6      2096451     hda6

   3        7     1004031    hda7


   3       64     20039544   hdb
   3       65     128488       hdb1
   3       66     19904535   hdb2


  22      64     29897280   hdd
  22      65     29896933   hdd1

 

5. /dev/hda7 디스크의 ext3  파일 시스템으로 생성

[command]# mkfs.ext3 /dev/hda7
mke2fs 1.35 (28-Feb-2004)

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
125696 inodes, 251007 blocks
12550 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=260046848
8 block groups
32768 blocks per group, 32768 fragments per group
15712 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376
 
Writing inode tables: done                           
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

※ 참고

mkfs.ext3 명령어와 mkfs -j 명령어가 동일하다.

[command]# mkfs.ext3 /dev/hda7

[command]# mkfs -j /dev/hda7

 

6. /dev/hda7 디스크의 mount 위치 디렉토리 생성 

[command]# mkdir /ext3_data

 

7. /dev/hda7 디스크를 /ext3_data 디렉토리로 Mount

[command]# df -h 

Filesystem              Size    Used    Avail     Use%   Mounted on
/dev/hdb2              19G      11G     7.1G     61%     /
/dev/hdb1              122M    8.5M   107M    8%       /boot
none                      252M       0      252M    0%       /dev/shm
/dev/hdd1              29G      261M   27G      1%      /data


[command]# mount /dev/hda7 /ext3_data


[command]# df -h
Filesystem              Size    Used    Avail     Use%   Mounted on
/dev/hdb2              19G      11G     7.1G     61%     /
/dev/hdb1              122M    8.5M   107M    8%       /boot
none                      252M       0      252M    0%       /dev/shm
/dev/hdd1              29G      261M   27G      1%      /data

/dev/hda7            966M  18M     899M   2%    /ext3_data

 

8. /ext3_data 디렉토리의 파일 생성 테스트

[command]# cd /ext3_data

 

[command]# ls
lost+found


[command]# touch test.file


[command]# ls 
lost+found  test.file

 

 

9. /ext3_data 디렉토리의 Unmount

[command]# pwd

/ext3_data

 

[command]# cd ..

 

[command]# pwd
/

 

[command]# umount /ext3_data/

 

[command]# df -h    
Filesystem              Size    Used    Avail     Use%   Mounted on
/dev/hdb2              19G      11G     7.1G     61%     /
/dev/hdb1              122M    8.5M   107M    8%       /boot
none                      252M       0      252M    0%       /dev/shm
/dev/hdd1              29G      261M   27G      1%      /data

 

10. Rebooting 시 /ext3_data 디렉토리 Static Mount

  - Device 으로 Mount 하는 경우

[command]# vi /etc/fstab

--> 설정 추가
/dev/hda7               /ext3_data              ext3    defaults        0 0

 

[command]# cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/                /                   ext3      defaults                  1 1
LABEL=/boot        /boot             ext3      defaults                 1 2
none                    /dev/pts        devpts   gid=5,mode=620   0 0
none                    /dev/shm       tmpfs    defaults                 0 0
none                    /proc              proc      defaults                 0 0
none                    /sys               sysfs     defaults                 0 0
/dev/hda6            swap             swap    defaults                 0 0
/dev/hdd1            /data             ext3      defaults                 0 0
/dev/hda7          /ext3_data    ext3     defaults                0 0


[command]# df -h    
Filesystem              Size    Used    Avail     Use%   Mounted on
/dev/hdb2              19G      11G     7.1G     61%     /
/dev/hdb1              122M    8.5M   107M    8%       /boot
none                      252M       0      252M    0%       /dev/shm
/dev/hdd1              29G      261M   27G      1%      /data

 

  - Device의 LABEL으로 Mount 하는 경우
     = Device 의 LABEL 확인

[command]# e2label /dev/hda7

[command]#

     = Device 의 LABEL 설정

 

[command]# e2label /dev/hda7 /ext3_data

[command]# e2label /dev/hda7
/ext3_data

 

[command]# vi /etc/fstab

--> 설정 추가
LABEL=/ext3_data               /ext3_data              ext3    defaults        0 0

 

[command]# cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/                        /                   ext3      defaults                  1 1
LABEL=/boot                /boot             ext3      defaults                 1 2
none                            /dev/pts        devpts   gid=5,mode=620   0 0
none                            /dev/shm       tmpfs    defaults                 0 0
none                            /proc              proc      defaults                 0 0
none                            /sys               sysfs     defaults                 0 0
/dev/hda6                    swap             swap    defaults                 0 0
/dev/hdd1                    /data             ext3      defaults                 0 0
LABEL=/ext3_data   /ext3_data    ext3     defaults                0 0

 

[command]# df -h    
Filesystem              Size    Used    Avail     Use%   Mounted on
/dev/hdb2              19G      11G     7.1G     61%     /
/dev/hdb1              122M    8.5M   107M    8%       /boot
none                      252M       0      252M    0%       /dev/shm
/dev/hdd1              29G      261M   27G      1%      /data


 
11. mount 명령어를 이용한 /etc/fstab 설정 파일의 파일 시스템 Mount 

[command]# mount -a


[command]# df -h
Filesystem              Size    Used    Avail     Use%   Mounted on
/dev/hdb2              19G      11G     7.1G     61%     /
/dev/hdb1              122M    8.5M   107M    8%       /boot
none                      252M       0      252M    0%       /dev/shm
/dev/hdd1              29G      261M   27G      1%      /data

/dev/hda7            966M  18M     899M   2%    /ext3_data


[command]#

  

12. Troubleshtooing

- 이 슈  사 항 : /ext3_data 디렉토리 umount 시 에러 메시지 발생 

- 에러 메시지 : umount: /ext3_data: device is busy 

[command]# df -h
Filesystem              Size    Used    Avail     Use%   Mounted on
/dev/hdb2              19G      11G     7.1G     61%     /
/dev/hdb1              122M    8.5M   107M    8%       /boot
none                      252M       0      252M    0%       /dev/shm
/dev/hdd1              29G      261M   27G      1%      /data

/dev/hda7            966M  18M     899M   2%    /ext3_data

 

[command]# cd /ext3_data


[command]# pwd

/ext3_data

 

[command]# umount /ext3_data

umount: /ext3_data: device is busy
umount: /ext3_data: device is busy

- 원 인  분 석 : /ext3_data 디렉토리가 사용중이라서 umount 할 수 없다. 

- 해 결 방 안

1. /ext3_data 디렉토리 안에서작업하는 사용자를 모두 나오고 umount 명령어로 마운트 해제를 한다.
2. fuser 명령어를 이용한 강제적으로 연결을 해제 한다. (권장하지 않음)

     - fuser 명령어를 이용한 /ext3_data 디렉토리 사용자 확인 및 강제적으로 연결 해제

[command]# fuser -vm /ext3_data

                              USER        PID   ACCESS  COMMAND
/ext3_data/          root       2999     ..c..        bash

 

[command]# cd ..

 

[command]# fuser -km /ext3_data


[command]# pwd
/
[command]# umount /ext3_data

 

[command]# df -h    
Filesystem              Size    Used    Avail     Use%   Mounted on
/dev/hdb2              19G      11G     7.1G     61%     /
/dev/hdb1              122M    8.5M   107M    8%       /boot
none                      252M       0      252M    0%       /dev/shm
/dev/hdd1              29G      261M   27G      1%      /data

 [Tip.] fuser 명령어를 이용하여 강제적으로 /ext3_data 디렉토리 사용자를 죽임(Kill)

[command]# fuser -km /ext3_data

--> [주의 사항] : /ext3_data 디렉토리 안의 작업중인 정보가 손실 될 수 있다.