하드디스크관리

2024. 11. 15. 15:34b정리/이것이 리눅스다-우분투-3판

728x90
반응형

https://www.youtube.com/watch?v=QOd7fTcoI4k&list=PLqTUMsvO70nnPQ42mtOKCgzlXeIy8GB0U&index=32

https://www.youtube.com/watch?v=RGsKOAQNzGI&list=PLqTUMsvO70nnPQ42mtOKCgzlXeIy8GB0U&index=33

 

1. 파티셔닝

fdis /dev/sdb

root@ServerA:~# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.39.3).
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.
Created a new DOS (MBR) disklabel with disk identifier 0x440e2535.

Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty MBR (DOS) partition table
   s   create a new empty Sun partition table


Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039):

Created a new partition 1 of type 'Linux' and of size 20 GiB.

Command (m for help): p
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x440e2535

Device     Boot Start      End  Sectors Size Id Type
/dev/sdb1        2048 41943039 41940992  20G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

 

2. 파일시스템 생성

mkfs.ext4

root@ServerA:~# mkfs.ext4 /dev/sdb1
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 5242624 4k blocks and 1310720 inodes
Filesystem UUID: 5121833e-67d1-4cb6-bc53-cad9292475b1
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

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

 

3. mount 및 /etc/fstab 설정

root@ServerA:~# mkdir /mydata
root@ServerA:~# cp /boot/vmlinuz-6.
vmlinuz-6.11.7            vmlinuz-6.8.0-47-generic  vmlinuz-6.8.0-48-generic
root@ServerA:~# cp /boot/vmlinuz-6.11.7 /mydata/test1
root@ServerA:~# ls /mydata/
test1
root@ServerA:~# mount /dev/sdb1 /mydata
root@ServerA:~# ls /mydata
lost+found
root@ServerA:~# cp /boot/vmlinuz-6.11.7 /mydata/test2
root@ServerA:~# ls /mydata/
lost+found  test2
root@ServerA:~# umount /dev/sdb1
root@ServerA:~# ls /mydata
test1

 

vi /etc/fstab

재시작 마운트 확인

root@ServerA:~# df
파일 시스템     1K-블록     사용     가용 사용% 마운트위치
tmpfs            396644     1848   394796    1% /run
/dev/sda2      81984920 40978796 36795592   53% /
tmpfs           1983216        0  1983216    0% /dev/shm
tmpfs              5120        0     5120    0% /run/lock
/dev/sdb1      20465232    13096 19387228    1% /mydata
tmpfs            396640      100   396540    1% /run/user/0
root@ServerA:~# ls /dev/sdb1
/dev/sdb1
root@ServerA:~# ls /mydata/
lost+found  test2
반응형