새소식

인기 검색어

Linux

5/11 파티션 생성, mount 실습

  • -
디스크 관리
파일시스템 & 스왑메모리
논리볼륨 관리

디스크
https://www.youtube.com/watch?v=7n71z7KIoXo

디스크 구매 -> 연결 -> 파티션 -> 포맷

디스크 파티션 
- MBR
    파티션 레이아웃을 파티션 테이블에 저장
    부팅할수 있는 파티션 정보를 갖고 있다.
    섹터 주소를 4byte로 저장 -> 최대 2TB 까지 저장 가능

- GPT
    - 파티션 테이블은 128개 까지 가능
    - 64bit -> 8ZB

e-ide : 핫 플러깅 x
sata : 핫 플러깅
scsi : 핫 플러깅





 

예제 ) 1G, 2G 파티션을 생성하시오.
  222  lsblk
  223  poweroff
  224  lsblk
  225  sudo fdisk /dev/vdb
  226  lsblk n-> ... ->w
  227  partprobe /dev/vdb 
  228  sudo partprobe /dev/vdb

3G ____  1G
        1G      +    2G     X

-----------------------------------------------------------
fdisk, gdisk : 파티션 생성
mkfs  : 파일 시스템 만들기
mkfs.ext4 : ext4 파일 시스템 생성
mkfs.ext3 : ext3 파일 시스템 생성
mkfs.ext2 : ext2 파일 시스템 생성

blkid : 파일 시스템 확인
df : 파일 시스템 확인 ( -Th)
lsblk :  파일 시스템 확인

mount : 마운팅 포인트에 디스크 마운트
    -a /etc/fstable 에 있는 장치 모두 마운트 
umount :  마운트 해제
    -a : 모든 장치 마운츠 해제




[user@localhost ~]$ sudo fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x4453ab8f.

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): 1
First sector (2048-41943039, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +2G
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (4196352-41943039, default 4196352): 
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-41943039, default 41943039): +2G
Partition 2 of type Linux and of size 2 GiB is set

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (8390656-41943039, default 8390656): +2G
Value out of range.
First sector (8390656-41943039, default 8390656): 
Using default value 8390656
Last sector, +sectors or +size{K,M,G} (8390656-41943039, default 41943039): +2G
Partition 3 of type Linux and of size 2 GiB is set

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): p
Selected partition 4
First sector (12584960-41943039, default 12584960): 
Using default value 12584960
Last sector, +sectors or +size{K,M,G} (12584960-41943039, default 41943039): +2G
Partition 4 of type Linux and of size 2 GiB is set

Command (m for help): p

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos
Disk identifier: 0x4453ab8f

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     4196351     2097152   83  Linux
/dev/vdb2         4196352     8390655     2097152   83  Linux
/dev/vdb3         8390656    12584959     2097152   83  Linux
/dev/vdb4        12584960    16779263     2097152   83  Linux

 


# /dev/vdb
# 파티션 생성
# 주 파티션 2G 2G 2G -> ext4 로 포맷
# 확장 파티션 2G 2G 2G 2G  -> xfs로 포맷
 
/dev/vdb1   -> mount /mnt/disk1
/dev/vdb2   -> mount /mnt/disk2
/dev/vdb3   -> mount /mnt/disk3
------------------------------------------------------------------------------

[user@localhost ~]$ sudo fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (1,4, default 1): 1
First sector (2048-41943039, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4196351, default 4196351): +2G
Value out of range.
Last sector, +sectors or +size{K,M,G} (2048-4196351, default 4196351): 
Using default value 4196351
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): p

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos
Disk identifier: 0x976ab5cb

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     4196351     2097152   83  Linux
/dev/vdb2         4196352     8390655     2097152   83  Linux
/dev/vdb3         8390656    12584959     2097152   83  Linux

Command (m for help): p

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos
Disk identifier: 0x976ab5cb

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     4196351     2097152   83  Linux
/dev/vdb2         4196352     8390655     2097152   83  Linux
/dev/vdb3         8390656    12584959     2097152   83  Linux

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): e
Selected partition 4
First sector (12584960-41943039, default 12584960): 
Using default value 12584960
Last sector, +sectors or +size{K,M,G} (12584960-41943039, default 41943039): 
Using default value 41943039
Partition 4 of type Extended and of size 14 GiB is set

Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (12587008-41943039, default 12587008): 
Using default value 12587008
Last sector, +sectors or +size{K,M,G} (12587008-41943039, default 41943039): +2G
Partition 5 of type Linux and of size 2 GiB is set

Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (16783360-41943039, default 16783360): 
Using default value 16783360
Last sector, +sectors or +size{K,M,G} (16783360-41943039, default 41943039): +2G
Partition 6 of type Linux and of size 2 GiB is set

Command (m for help): p

Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos
Disk identifier: 0x976ab5cb

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     4196351     2097152   83  Linux
/dev/vdb2         4196352     8390655     2097152   83  Linux
/dev/vdb3         8390656    12584959     2097152   83  Linux
/dev/vdb4        12584960    41943039    14679040    5  Extended
/dev/vdb5        12587008    16781311     2097152   83  Linux
/dev/vdb6        16783360    20977663     2097152   83  Linux

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

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

[user@localhost ~]$ sudo mkfs.ext4 /dev/vdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912

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

[user@localhost ~]$ sudo mkfs.ext4 /dev/vdb2
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912

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

[user@localhost ~]$ sudo mkfs.ext4 /dev/vdb3
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912

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

[user@localhost ~]$ sudo mkfs.xfs /dev/vdb4
mke2fs 1.42.9 (28-Dec-2013)
mkfs.xfs: inode_size (128) * inodes_count (0) too big for a
	filesystem with 0 blocks, specify higher inode_ratio (-i)
	or lower inode count (-N).

[user@localhost ~]$ sudo mkfs.xfs /dev/vdb5
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912

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

[user@localhost ~]$ sudo mkfs.xfs /dev/vdb6
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912

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


[user@localhost ~]$ sudo mount -t ext4 /dev/vdb1 /mnt/disk1
mount: mount point /mnt/disk1 does not exist
[user@localhost ~]$ sudo mkdir /mnt/disk1
[user@localhost ~]$ sudo mount -t ext4 /dev/vdb1 /mnt/disk1
[user@localhost ~]$ sudo mkdir /mnt/disk2
[user@localhost ~]$ sudo mount -t ext4 /dev/vdb2 /mnt/disk2
[user@localhost ~]$ sudo mkdir /mnt/disk3
[user@localhost ~]$ sudo mount -t ext4 /dev/vdb3 /mnt/disk3
[user@localhost ~]$ lsblk
NAME            MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda             252:0    0  20G  0 disk 
├─vda1          252:1    0   1G  0 part /boot
└─vda2          252:2    0  19G  0 part 
  ├─centos-root 253:0    0  17G  0 lvm  /
  └─centos-swap 253:1    0   2G  0 lvm  [SWAP]
vdb             252:16   0  20G  0 disk 
├─vdb1          252:17   0   2G  0 part /mnt/disk1
├─vdb2          252:18   0   2G  0 part /mnt/disk2
├─vdb3          252:19   0   2G  0 part /mnt/disk3
├─vdb4          252:20   0   1K  0 part 
├─vdb5          252:21   0   2G  0 part 
└─vdb6          252:22   0   2G  0 part 
[user@localhost ~]$ blkid
[user@localhost ~]$ sudo blkid
/dev/vda1: UUID="923745de-1bfd-4c7e-89a1-5895651ee0ec" TYPE="xfs" 
/dev/vda2: UUID="pwT7km-pGGa-6O1Y-k5UD-cg74-aZiV-oZ5b2J" TYPE="LVM2_member" 
/dev/vdb1: UUID="181ecf87-b881-4a18-b069-b3486efae746" TYPE="ext4" 
/dev/vdb2: UUID="993ed39e-668f-4d16-8691-778e8a84ee1e" TYPE="ext4" 
/dev/vdb3: UUID="a95940dc-b7c0-4850-9956-cb406ef0fc87" TYPE="ext4" 
/dev/vdb5: UUID="1fc67f85-0f9e-4088-bc61-7ee7014eff17" TYPE="xfs" 
/dev/vdb6: UUID="72b9e036-c87b-4a2e-baa7-d7a14934aadf" TYPE="xfs" 
/dev/mapper/centos-root: UUID="1801dee2-e598-4d71-a398-9fb9f069df97" TYPE="xfs" 
/dev/mapper/centos-swap: UUID="10362ce3-2c62-483b-8e06-18dad666a9b0" TYPE="swap" 


[user@localhost ~]$ 

 mkdir /mnt/disk{1,2,3}

lsblk -f

sudo unmount /dev/vdb1 /mnt/disk1

ls -al /mnt/disk1/

 

sudo mount -a

 

lsblk -f | tail -4

sudo lsblk -f | tail -4 >> /etc/fstab

vi /etc/fstab

sudo -s

 

 

'Linux' 카테고리의 다른 글

5/18 firewall, rich 규칙 실습  (0) 2021.05.18
5/17 find 명령어, ssh, ntp  (0) 2021.05.17
5/11 스케줄링(crontab ..)  (0) 2021.05.11
5/11 접근제어리스트(ACL) 설정 관리  (0) 2021.05.11
5/10 사용자 및 그룹 관리  (0) 2021.05.10
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.