본문 바로가기

NetWork

UBUNTU 12.0.4 HDD Mount

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
sudo fdisk -l


zcommit@ds3:~$ sudo fdisk -l
[sudo] password for zcommit:

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004afa2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2046     3999743     1998849    5  Extended
/dev/sda2   *     3999744    16775167     6387712   83  Linux
/dev/sda5            2048     3999743     1998848   82  Linux swap / Solaris

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table


2. 디스크 파티션 생성

sudo fdisk /dev/sdb


zcommit@ds3:~$ sudo fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x45e8d37f.
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)

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): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-16777215, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215):
Using default value 16777215

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

디스크를 하나의 파티션으로 사용하기 위해 위와 같이 생성했다.
(/dev/sdc 디스크도 같은 방법으로 파티션 생성)

3. 파티션 포맷

sudo mkfs.ext4 /dev/sdb1
/dev/sdb1 파티션을 ext4 파일시스템으로 포맷한다.

zcommit@ds3:~$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
524288 inodes, 2096896 blocks
104844 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 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

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

(/dev/sdc1 파티션도 같은 방법으로 포맷)

4. 디스크 파티션 정보 확인

sudo fdisk -l

zcommit@ds3:~$ sudo fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004afa2

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2046     3999743     1998849    5  Extended
/dev/sda2   *     3999744    16775167     6387712   83  Linux
/dev/sda5            2048     3999743     1998848   82  Linux swap / Solaris

Disk /dev/sdb: 8589 MB, 8589934592 bytes
86 heads, 1 sectors/track, 195083 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45e8d37f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    16777215     8387584   83  Linux

Disk /dev/sdc: 8589 MB, 8589934592 bytes
86 heads, 1 sectors/track, 195083 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2d4199f1

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    16777215     8387584   83  Linux

새로 추가한 디스크에 파티션이 만들어졌다.

5. 파티션을 마운트할 디렉토리 생성

sudo mkdir /data1 /data2

6. 파티션 자동 마운트

sudo vi /etc/fstab
파티션 자동 마운트를 위해 맨 아래 두 줄을 추가했다.

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda2 during installation
UUID=b6630f37-a335-4055-bda0-fb46ad2e85a1 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=a5018201-432f-400c-ac84-6ac66a00b424 none            swap    sw              0       0
# Hadoop data disk
/dev/sdb1   /data1  ext4    defaults    0   1
/dev/sdc1   /data2  ext4    defaults    0   1

7. 파일시스템 마운트

sudo mount -a
fstab에 설정된 모든 파일시스템을 마운트한다.

8. 파일시스템 및 디스크 용량 확인

df -hT

zcommit@ds3:~$ df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/sda2      ext4      6.1G  1.5G  4.3G  26% /
udev           devtmpfs 1000M  4.0K 1000M   1% /dev
tmpfs          tmpfs     403M  276K  403M   1% /run
none           tmpfs     5.0M     0  5.0M   0% /run/lock
none           tmpfs    1007M     0 1007M   0% /run/shm
/dev/sdb1      ext4      8.0G  249M  7.4G   4% /data1
/dev/sdc1      ext4      8.0G  249M  7.4G   4% /data