1. virtualbox에 새 하드 드라이브 추가.

하드를 추가하고자 하는 os를 선택하고 설정->저장소->컨트롤러->하드디스크 추가하기를 클릭한다.

새 디스크 만들기를 클릭하고

하드 드라이브 파일 종류를 선택해야 하는데 그냥 기본으로 두었다.

하드 드라이브에 용량이 넉넉하므로 고정 크기로 생성하자.

하드디스크 파일이 저장될 위치를 선택하고 용량을 정하도록 하자.

그러면 새로운 디스크가 생성된다.

저장소에 50GB의 extrakHdd가 생성된 것을 볼 수 있다.
우분투에서 터미널을 실행하자.
터미널에 다음과 같이 입력한다.
그러면 다음과 같은 정보를 보여준다.
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 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 identifier가 0으로 되어 있다. 왠지 0이면 안될 것 같다.
새로운 하드 드라이브라서 그런걸까..
어쨋든 새로운 하드에 파티션을 잡아주도록 하자.
위와 같이 명령을 치면 아래와 같은 창이 나온다.
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x06690ba0.
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)
m을 입력하면 도와준다고 하니 m을 입력해보았다.
그러니 여러 명령어들이 나오는데 그중에 우리가 할 것은 파티션을 나누는 것이니 n을 누르도록 하자.
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
파티션 타입을 입력하란다. p를 입력한다.
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-104857599, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
Command (m for help): w
그 다음부터는 그냥 엔터만 눌러서 기본 설정으로 진행하도록 했다.
다시 한번 디스크 정보를 출력해보자.
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
22 heads, 22 sectors/track, 216647 cylinders, total 104857600 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: 0x015ed627
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104857599 52427776 83 Linux
Disk identifier값이 생성된 것을 볼 수 있다.
추가로 /dev/sdb1로 파티션이 생성되었다.
파티션을 나누었으니 포맷을 하도록 하자.
아래와 같이 입력하면 sdb1을 포맷 한다.
$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13106944 blocks
655347 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
하드디스크에 접근을 하려면 마운트를 해야한다.
마운트를 위한 폴더를 하나 생성하자.
그 다음은 생성한 폴더에 마운트를 하면 된다.
$ sudo mount -t ext4 /dev/sdb1 /extrahdd
/extrahdd에 새로운 하드디스크가 마운트 되었다.
먼저 하드디스크의 ID를 알아내보자.
$ ls -l /dev/disk/by-uuid/
lrwxrwxrwx 1 root root 10 7월 8 13:17 8ce97b57-c827-49c2-b87b-1343ecc07e25 -> ../../sdb1
lrwxrwxrwx 1 root root 10 7월 8 12:51 c41f4ec9-9190-4416-af0a-9d0365d8b4e7 -> ../../sda1
lrwxrwxrwx 1 root root 10 7월 8 12:51 db00ae6a-9322-4b89-84e7-c1df28049121 -> ../../sda5
우리가 생성한 sdb1의 uuid가 나온다. 이것을 잘 기억해 두었다가 설정 파일에 적어주자.
먼저 설정 파일을 열고
# /extrahdd on /dev/sdb1.
UUID=8ce97b57-c827-49c2-b87b-1343ecc07e25 /extrahdd ext4 errors=remount-ro 0 1
위와 비슷한 내용이 있을 것이다.
위의 내용을 추가했다.
재 부팅 후 확인.
우분투를 재 부팅 한 후 터미널에 다음과 같이 입력했다.
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 95G 3.5G 87G 4% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 396M 868K 395M 1% /run
none 5.0M 4.0K 5.0M 1% /run/lock
none 2.0G 220K 2.0G 1% /run/shm
none 100M 40K 100M 1% /run/user
/dev/sdb1 50G 52M 47G 1% /extrahdd
/dev/sdb1이 /extrahdd에 잘 마운트 된것이 보인다.
하드디스크를 추가 한뒤 아무나 쓸 수 있는 것이 아니다. 리눅스는 소유권에 관한 개념이 철저하기 때문에 각각의 사용자에 대해 쓸수 있는 폴더를 만들어 주어야 한다.
nold를 위한 폴더를 하나 만들어 주고 소유권을 주도록 하자.
$ sudo mkdir extrahdd/nold
$ sudo chown nold:nold /extrahdd/nold/
그리고 나서 /extrahdd/nold/에 대한 정보를 보면,
total 28
drwxr-xr-x 4 root root 4096 7월 8 22:38 ./
drwxr-xr-x 26 root root 4096 7월 8 20:37 ../
drwx------ 2 root root 16384 7월 8 13:17 lost+found/
drwxr-xr-x 2 nold nold 4096 7월 8 22:38 nold/
위와 같이 nold폴더의 소유권이 nold로 바뀌었다.
확인차 폴더를 하나 만들어 보자.
$ cd /extrahdd/nold/
$ mkdir test
$ ll
total 12
drwxr-xr-x 3 nold nold 4096 7월 8 22:40 ./
drwxr-xr-x 4 root root 4096 7월 8 22:38 ../
drwxrwxr-x 2 nold nold 4096 7월 8 22:41 test/
위와같이 정상적으로 동작 하는 것을 볼 수 있다.