본문 바로가기

보물창고/보물 모음

virtualbox centos usb 리눅스 외장 하드디스크 포맷 방법

반응형

virtualbox centos usb 리눅스 외장 하드디스크 포맷 방법





virtualbox에 usb 외장 하드 디스크를 인식 시키는 방법과

centos에서 외장 드라이브를 포맷하는 방법을 정리했습니다







host 컴퓨터는 windows입니다

외장하드를 usb로 인식시킨 상태 입니다




host컴퓨터에서 인식한 외장하드를 virtualbox내부 centos에서 인식하도록 설정하는 방법 입니다

virtualbox 메뉴중 '장치" -> "USB 장치" -> "Seagate BUP Slim BK"를 선택합니다

선택을하면 해당 라인에 V 로 체크가 됨을 확인할 수 있습니다

Seagate BUP Slim BK 이 이름은 각 외장하드 드라이브 이름마다 다릅니다




virtualbox에서 인식을 하면 host컴퓨터인 windows에서는 해당 드라이브가 목록에서 사라집니다





지금 부터는 centos내부에서 외장하드를 포맷하는 방법입니다


fdisk -l

리눅스에 마운트 된것을 확인합니다 

외장하드가 /dev/sdb1위치에 NTFS타입으로 있음이 확인됩니다




fdisk /dev/sdb1

fdisk는 디스크 파티션 관리자 입니다

이 명령어로 /dev/sdb1에 마운트된 외징하드의 파티션을 지우려고 합니다




p 를 명령

/dev/sdb1로 마운트된 디스크의 파티션을 확인합니다




m 을 명령

fdisk에서 사용할 수 있는 명령어 모음 입니다




d 를 명령

기존에 있는 파티션을 모두 삭제합니다

저는 1번부터 4번까지 삭제를 진행 했습니다




p 를 명령

파티션을 모두 삭제한 현재 디스크의 파티션을 다시 확인합니다




n 을 명령

p 를 명령

엔터

엔터

새로운 파티션을 생성합니다




w 를 명령

설정한 파티션을 저장하고 나옵니다




mkfs -t ext3 /dev/sdb1

/dev/sdb1에 마운트된 디스크를 ext3형식으로 포맷중입니다

ext3 형식으로 포맷이 완료 되었습니다




mount -t ext3 /dev/sdb1 /mnt 

/mnt 위치로 외장하드를 마운트를합니다






스크립트 전체 백업

[root@localhost dev]# fdisk -l

Disk /dev/sda: 137.4 GB, 137438953472 bytes

255 heads, 63 sectors/track, 16709 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: 0x0009c402


Device Boot Start End Blocks Id System

/dev/sda1 * 1 64 512000 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 64 16710 133704704 8e Linux LVM


Disk /dev/mapper/VolGroup-lv_root: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 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: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 4227 MB, 4227858432 bytes

255 heads, 63 sectors/track, 514 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: 0x00000000


Disk /dev/mapper/VolGroup-lv_home: 79.0 GB, 78995521536 bytes

255 heads, 63 sectors/track, 9603 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: 0x00000000


Disk /dev/sdb: 1000.2 GB, 1000204885504 bytes

255 heads, 63 sectors/track, 121601 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: 0x1bd9803b


Device Boot Start End Blocks Id System

/dev/sdb1 * 1 121602 976761559+ 7 HPFS/NTFS

[root@localhost dev]# 

[root@localhost dev]# fdisk /dev/sdb1


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/sdb1: 1000.2 GB, 1000203836928 bytes

255 heads, 63 sectors/track, 121601 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: 0x6e697373


This doesn't look like a partition table

Probably you selected the wrong device.


Device Boot Start End Blocks Id System

/dev/sdb1p1 ? 120528 234814 918008208 4f QNX4.x 3rd part

Partition 1 does not end on cylinder boundary.

/dev/sdb1p2 ? 119381 153271 272218546+ 73 Unknown

Partition 2 does not end on cylinder boundary.

/dev/sdb1p3 ? 113202 147075 272087568 2b Unknown

Partition 3 does not end on cylinder boundary.

/dev/sdb1p4 ? 177064 177067 27487 61 SpeedStor

Partition 4 does not end on cylinder boundary.


Partition table entries are not in disk order


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): d

Partition number (1-4): 1

Warning: partition 1 has empty type


Command (m for help): d 

Partition number (1-4): 2


Command (m for help): d

Partition number (1-4): 3


Command (m for help): d

Selected partition 4


Command (m for help): 4

4: unknown command

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/sdb1: 1000.2 GB, 1000203836928 bytes

255 heads, 63 sectors/track, 121601 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: 0x6e697373


Device Boot Start End Blocks Id System


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-121601, default 1): 

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-121601, default 121601): 

Using default value 121601


Command (m for help): p


Disk /dev/sdb1: 1000.2 GB, 1000203836928 bytes

255 heads, 63 sectors/track, 121601 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: 0x6e697373


Device Boot Start End Blocks Id System

/dev/sdb1p1 1 121601 976760001 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 22: Invalid argument.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

[root@localhost dev]# 

[root@localhost dev]# mkfs -t ext3 /dev/sdb1

mke2fs 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

61054976 inodes, 244190389 blocks

12209519 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

7453 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, 214990848


Writing inode tables: done 

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 35 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.


bash: fdisl: command not found

[root@localhost dev]# fdisk -l


[root@localhost /]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

50G 4.2G 43G 10% /

tmpfs 939M 236K 939M 1% /dev/shm

/dev/sda1 477M 59M 393M 13% /boot

/dev/mapper/VolGroup-lv_home

73G 2.4G 67G 4% /home

/dev/sdb1 917G 200M 871G 1% /media/c45c1ad6-9ad7-4313-b84b-24289e99b0d2

[root@localhost /]# umount -t ext3 /dev/sdb1 /mnt

umount: /mnt: not mounted

[root@localhost /]# umount -t ext3 /dev/sdb1 /



반응형