우분투 HDD추가 마운법
페이지 정보
작성자 정성규 댓글 0건 조회 17,913회 작성일 12-06-26 16:45본문
- 우분투 서버(Ubuntu 10.04 LTS)에서 실행한 내용임 -
처음 시스템을 구성할 때 자주 사용하게 되는 커맨드들일텐데, 자주 써 보질 않아 계속 인터넷을 찾아보며 셋팅을 하고 있다. 가장 기본적인 내용이라 간단하게 정리를 해 두기로 하자.
기본적인 것들은 이미 설치 CD로 다 되었다. 하드디스크(HDD) 하나에 자동파티셔닝으로 간단하게 설치를 마치고, 이제 남는 하드디스크를 달아야겠지. 메인보드에 하드를 달고 나서 우분투로 부팅... 일일이 "sudo"를 앞에 달기 귀찮아서 "sudo -i"로 root 쉘을 열어서 사용하기로 한다. ^^;;
- 파티션 설정 (Partitioning)
root@server:~# fdisk -l
Disk /dev/sda: 37.0 GB, 37019566080 bytes
255 heads, 63 sectors/track, 4500 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bb50f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 4311 34619392 83 Linux
/dev/sda2 4311 4501 1529857 5 Extended
/dev/sda5 4311 4501 1529856 82 Linux swap / Solaris
Disk /dev/sdb: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dc79f
Device Boot Start End Blocks Id System
/dev/sdb1 1 30402 244197376 83 Linux
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
/dev/sdc1 1 60801 488384001 83 Linux
Disk /dev/sda: 37.0 GB, 37019566080 bytes
255 heads, 63 sectors/track, 4500 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bb50f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 4311 34619392 83 Linux
/dev/sda2 4311 4501 1529857 5 Extended
/dev/sda5 4311 4501 1529856 82 Linux swap / Solaris
Disk /dev/sdb: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dc79f
Device Boot Start End Blocks Id System
/dev/sdb1 1 30402 244197376 83 Linux
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
/dev/sdc1 1 60801 488384001 83 Linux
위의 내용은 모든 파티션 생성이 끝난 후의 내용이다. 이미 다 해 버려서...^^;; 포스팅을 위해 한 번 반복을 해 보자.
새로 추가하려는 하드는 "/dev/sdc"이다. 원래는 윈도우즈에서 사용하던, NTFS 파일시스템이었는데 이미 파티션 설정을 마쳤더니 저렇게 되었다. 하여간, 여기서 다시 파티션 삭제 후 다시 설정을 해 보자면, 일단 "fdisk /dev/sdc"로 시작을 한다.
root@server:~# fdisk /dev/sdc
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
/dev/sdc1 1 60801 488384001 83 Linux
Command (m for help): d
Selected partition 1
Command (m for help): p
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
Command (m for help):
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
/dev/sdc1 1 60801 488384001 83 Linux
Command (m for help): d
Selected partition 1
Command (m for help): p
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
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-60801, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-60801, default 60801):
Using default value 60801
Command (m for help): p
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
/dev/sdc1 1 60801 488384001 83 Linux
Command (m for help):
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-60801, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-60801, default 60801):
Using default value 60801
Command (m for help): p
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
/dev/sdc1 1 60801 488384001 83 Linux
Command (m for help):
이제 primary 파티션 "/dev/sdc1"이 만들어졌다. 위의 모든 내용을 디스크에 적용을 시키려면 "w"로 마무리.
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@server:~# fdisk -l
Disk /dev/sda: 37.0 GB, 37019566080 bytes
255 heads, 63 sectors/track, 4500 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bb50f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 4311 34619392 83 Linux
/dev/sda2 4311 4501 1529857 5 Extended
/dev/sda5 4311 4501 1529856 82 Linux swap / Solaris
Disk /dev/sdb: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dc79f
Device Boot Start End Blocks Id System
/dev/sdb1 1 30402 244197376 83 Linux
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
/dev/sdc1 1 60801 488384001 83 Linux
root@server:~#
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@server:~# fdisk -l
Disk /dev/sda: 37.0 GB, 37019566080 bytes
255 heads, 63 sectors/track, 4500 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bb50f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 4311 34619392 83 Linux
/dev/sda2 4311 4501 1529857 5 Extended
/dev/sda5 4311 4501 1529856 82 Linux swap / Solaris
Disk /dev/sdb: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dc79f
Device Boot Start End Blocks Id System
/dev/sdb1 1 30402 244197376 83 Linux
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4ca370e6
Device Boot Start End Blocks Id System
/dev/sdc1 1 60801 488384001 83 Linux
root@server:~#
- ext4 파일 시스템으로 포맷 (Formatting)
root@server:~# mkfs.ext4 /dev/sdc1
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
30531584 inodes, 122096000 blocks
6104800 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
3727 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, 71663616, 78675968,
102400000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
root@server:~#
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
30531584 inodes, 122096000 blocks
6104800 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
3727 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, 71663616, 78675968,
102400000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
root@server:~#
별거 없다. "mkfs.ext4"에 여러가지 옵션이 있지만, 일단 지금은 그냥 기본 설정으로 진행한다. 포맷도 끝났다. 이제, 시스템에서 사용할 수 있도록 해 줘야지.
- 마운트 (Mounting)
일단, 마운트 할 위치가 필요하니 적당한 곳에 디렉토리를 하나 생성해 둔다.
root@server:/# cd /media
root@server:/media# ls
backup01 ntfs_mount
root@server:/media# mkdir temp
root@server:/media# ls
backup01 ntfs_mount temp
root@server:/media#
root@server:/media# ls
backup01 ntfs_mount
root@server:/media# mkdir temp
root@server:/media# ls
backup01 ntfs_mount temp
root@server:/media#
"temp"라는 디렉토리를 생성하였다. 이제 여기에 "/dev/sdc1"을 마운트시키자.
root@server:/media# mount -t ext4 /dev/sdc1 /media/temp
root@server:/media# mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/dev/sdb1 on /media/backup01 type ext4 (rw)
/dev/sdc1 on /media/temp type ext4 (rw)
root@server:/media# umount /dev/sdc1
root@server:/media# mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/dev/sdb1 on /media/backup01 type ext4 (rw)
root@server:/media#
root@server:/media# mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/dev/sdb1 on /media/backup01 type ext4 (rw)
/dev/sdc1 on /media/temp type ext4 (rw)
root@server:/media# umount /dev/sdc1
root@server:/media# mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/dev/sdb1 on /media/backup01 type ext4 (rw)
root@server:/media#
부팅할 때마다 자동으로 마운트가 되도록 하려면 "/etc/fstab"을 편집해 준다. 먼저, UUID를 확인하고,
root@server:/media# ls -l /dev/disk/by-uuid/
합계 0
lrwxrwxrwx 1 root root 10 2011-01-24 09:54 45c91d14-7296-42b4-9c83-c5150e0e2d2b -> ../../sda5
lrwxrwxrwx 1 root root 10 2011-01-24 12:23 5e09673e-29fa-47c7-9ff5-699095f6afe5 -> ../../sdc1
lrwxrwxrwx 1 root root 10 2011-01-24 09:54 d47174b5-11ea-4187-ab8a-b8721e48a78a -> ../../sda1
lrwxrwxrwx 1 root root 10 2011-01-24 10:55 fe0cd471-2846-402c-9d70-6a26ced35743 -> ../../sdb1
합계 0
lrwxrwxrwx 1 root root 10 2011-01-24 09:54 45c91d14-7296-42b4-9c83-c5150e0e2d2b -> ../../sda5
lrwxrwxrwx 1 root root 10 2011-01-24 12:23 5e09673e-29fa-47c7-9ff5-699095f6afe5 -> ../../sdc1
lrwxrwxrwx 1 root root 10 2011-01-24 09:54 d47174b5-11ea-4187-ab8a-b8721e48a78a -> ../../sda1
lrwxrwxrwx 1 root root 10 2011-01-24 10:55 fe0cd471-2846-402c-9d70-6a26ced35743 -> ../../sdb1
"/etc/fstab"을 편집.
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' 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/sda1 during installation
UUID=d47174b5-11ea-4187-ab8a-b8721e48a78a / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=45c91d14-7296-42b4-9c83-c5150e0e2d2b none swap sw 0 0
UUID=fe0cd471-2846-402c-9d70-6a26ced35743 /media/backup01 ext4 defaults 0 1
UUID=5e09673e-29fa-47c7-9ff5-699095f6afe5 /media/temp ext4 defaults 0 1
#
# Use 'blkid -o value -s UUID' 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/sda1 during installation
UUID=d47174b5-11ea-4187-ab8a-b8721e48a78a / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=45c91d14-7296-42b4-9c83-c5150e0e2d2b none swap sw 0 0
UUID=fe0cd471-2846-402c-9d70-6a26ced35743 /media/backup01 ext4 defaults 0 1
UUID=5e09673e-29fa-47c7-9ff5-699095f6afe5 /media/temp ext4 defaults 0 1
재부팅 해 보면 마운트 되어 있는 것을 볼 수 있을 것이다.
[이 게시물은 최고관리자님에 의해 2021-10-19 15:24:18 notebook에서 이동 됨]
댓글목록
등록된 댓글이 없습니다.