라즈베리파이용으로 배포된 이미지를 SD 카드에 구웠더니 16GB 용량인데도 root 파티션이 너무 작게 잡혀있네요~
4G 용량 이하로 이미지가 만들어졌는가 봅니다.
남아있는 공간을 할당하여 사이즈를 확장하는 방법입니다.
늘였다가 줄이기는 안됩니다. ( 먹통이 됩니다. )
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.4G 1.3G 112M 92% /
devtmpfs 460M 0 460M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 12M 452M 3% /run
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 667M 43M 625M 7% /boot
tmpfs 93M 0 93M 0% /run/user/0
[root@localhost ~]# fdisk /dev/mmcblk0
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): p
Disk /dev/mmcblk0: 15.8 GB, 15819866112 bytes, 30898176 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: 0x000cc7a5
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2048 1370111 684032 c W95 FAT32 (LBA)
/dev/mmcblk0p2 1370112 2369535 499712 82 Linux swap / Solaris
/dev/mmcblk0p3 2369536 5298175 1464320 83 Linux ( 이 부분을 지웠다가 다시 늘여줍니다. )
( 시작블럭이 같고 뒷쪽에 남아있는 영역을 사용하는 것은 기존 파일이 있더라도 가능한가 봅니다. )
Command (m for help): d
Partition number (1-3, default 3): 3
Partition 3 is deleted
Command (m for help): p
Disk /dev/mmcblk0: 15.8 GB, 15819866112 bytes, 30898176 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: 0x000cc7a5
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2048 1370111 684032 c W95 FAT32 (LBA)
/dev/mmcblk0p2 1370112 2369535 499712 82 Linux swap / Solaris
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):
First sector (2369536-30898175, default 2369536):
Using default value 2369536
Last sector, +sectors or +size{K,M,G} (2369536-30898175, default 30898175):
Using default value 30898175
Partition 3 of type Linux and of size 13.6 GiB is set
Command (m for help): p
Disk /dev/mmcblk0: 15.8 GB, 15819866112 bytes, 30898176 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: 0x000cc7a5
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 2048 1370111 684032 c W95 FAT32 (LBA)
/dev/mmcblk0p2 1370112 2369535 499712 82 Linux swap / Solaris
/dev/mmcblk0p3 2369536 30898175 14264320 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 16: Device or resource busy.
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 ~]# reboot
login as: root
root@192.168.1.3's password:
Last login: Wed May 8 13:57:11 2019 from 192.168.1.83
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.4G 1.3G 113M 92% /
devtmpfs 460M 0 460M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 12M 452M 3% /run
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 667M 43M 625M 7% /boot
tmpfs 93M 0 93M 0% /run/user/0
[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 = 2
The filesystem on /dev/mmcblk0p3 is now 3566080 blocks long.
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 14G 1.3G 13G 10% /
devtmpfs 460M 0 460M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 12M 452M 3% /run
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 667M 43M 625M 7% /boot
tmpfs 93M 0 93M 0% /run/user/0
늘어난 용량을 확인할 수가 있습니다.
이렇게 늘인 공간을 다시 줄이기는 안되는군요~
'라즈베리파이' 카테고리의 다른 글
[라즈베리파이] CentOS microSD 카드 백업 방법 (0) | 2019.05.13 |
---|---|
[라즈베리파이] 기본장치 소비전력 측정 (1) | 2019.05.09 |
[라즈베리파이] CentOS 7.x PHP 7.2 설치 방법 (0) | 2019.05.09 |
[라즈베리파이] CentOS 초기 root 비밀번호 (0) | 2019.05.08 |
[라즈베리파이] CentOS 7 이미지 다운로드 (0) | 2019.05.04 |