맛집 여행 캠핑 일상 생활

[라즈베리파이] CentOS microSD 공간 확장 본문

LINUX

[라즈베리파이] CentOS microSD 공간 확장

영은파더♥ 2024. 8. 10. 15:58
728x90

라즈베리파이2에 CentOS 이미지를 굽고 df -h 로 용량을 확인해보면 microSD 카드 용량 보다 훨씬 작게 잡혀있습니다.

루트 공간을 확장 시켜주는 방법입니다.

[root@localhost ~]# parted /dev/mmcblk0
GNU Parted 3.1
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit chs
(parted) print
Model: SD CBADS (sd/mmc)
Disk /dev/mmcblk0: 7650,197,34
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 7650,255,63.  Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags:

Number  Start      End        Type     File system     Flags
 1      0,130,2    36,247,18  primary  fat16           boot, lba
 2      36,247,19  99,46,10   primary  linux-swap(v1)
 3      99,46,11   318,17,18  primary  ext4

(parted) rm 3
Error: Partition(s) 3 on /dev/mmcblk0 have been written, but we have been unable
to inform the kernel of the change, probably because it/they are in use.  As a
result, the old partition(s) will remain in use.  You should reboot now before
making further changes.
Ignore/Cancel? i
(parted) print
Model: SD CBADS (sd/mmc)
Disk /dev/mmcblk0: 7650,197,34
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 7650,255,63.  Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags:

Number  Start      End        Type     File system     Flags
 1      0,130,2    36,247,18  primary  fat16           boot, lba
 2      36,247,19  99,46,10   primary  linux-swap(v1)

(parted) mkpart primary 99,46,11 7650,197,34
(parted) print
Model: SD CBADS (sd/mmc)
Disk /dev/mmcblk0: 7650,197,34
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 7650,255,63.  Each cylinder is 8225kB.
Partition Table: msdos
Disk Flags:

Number  Start      End          Type     File system     Flags
 1      0,130,2    36,247,18    primary  fat16           boot, lba
 2      36,247,19  99,46,10     primary  linux-swap(v1)
 3      99,46,11   7650,197,34  primary  ext4

(parted) quit
Information: You may need to update /etc/fstab.

[root@localhost ~]# sync
[root@localhost ~]# reboot

다시 로그인해서

[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.7G  1.2G  407M  75% /
devtmpfs        430M     0  430M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M   12M  451M   3% /run
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  286M   50M  237M  18% /boot
tmpfs            93M     0   93M   0% /run/user/0
[root@localhost ~]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0 58.6G  0 disk
├─mmcblk0p2 179:2    0  488M  0 part [SWAP]
├─mmcblk0p3 179:3    0 57.9G  0 part /
└─mmcblk0p1 179:1    0  286M  0 part /boot
[root@localhost ~]# resize2fs /dev/mmcblk0p3
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mmcblk0p3 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 8
The filesystem on /dev/mmcblk0p3 is now 15164544 blocks long.

[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        57G  1.2G   56G   3% /
devtmpfs        430M     0  430M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M   12M  451M   3% /run
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  286M   50M  237M  18% /boot
tmpfs            93M     0   93M   0% /run/user/0

이제 사이즈가 늘어난 것을 확인할 수 있습니다.

 

728x90
반응형
Trackback : | Comments :