배우고픈 공돌이

1. 커널 이미지 올리기 + fdisk로 파일시스템 확장하기 본문

ARM/BBBW

1. 커널 이미지 올리기 + fdisk로 파일시스템 확장하기

내 마음 아홉수 2017. 10. 14. 01:37

라즈베리파이와 같이 제공해준 커널이미지를 마이크로sd카드에 적재한다.



ssh로 접속할 때, 


id : debian / pwd : temppwd


루트계정을 사용할 때는,

debian의 패스워드를 한번 더 사용하면 된다. 

(한번 사용하면, 그 후로는 root로 바로 연결된다.)


/////////////////////////////////////////////////////////////////////////////


이후 중요한 것은, sd카드의 용량을 모두 사용하기 위해 파일 시스템을 확장해야한다.


라즈베리파이와는 다르게 hdmi-usb type A가 필요함으로


ssh환경에서 변경한다.


1. fdisk -l or df -k --human 을 사용하여 디스크 확인하기


root@beaglebone:/home/debian# df -k --human

Filesystem      Size  Used Avail Use% Mounted on

udev            216M     0  216M   0% /dev

tmpfs            49M  5.1M   44M  11% /run

/dev/mmcblk0p1  3.3G  2.6G  470M  85% /

tmpfs           243M     0  243M   0% /dev/shm

tmpfs           5.0M  4.0K  5.0M   1% /run/lock

tmpfs           243M     0  243M   0% /sys/fs/cgroup

tmpfs            49M  4.0K   49M   1% /run/user/1000


2. fdisk /dev/mmcblk0(BBB의 MMC가 잡고있는 마이크로SD카드의 장치 이름)으로 파티션 확인


root@beaglebone:/home/debian# fdisk /dev/mmcblk0


Welcome to fdisk (util-linux 2.29.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: 14.9 GiB, 15997075456 bytes, 31244288 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

Disklabel type: dos

Disk identifier: 0x7f863e1e


Device         Boot Start     End Sectors  Size Id Type

/dev/mmcblk0p1 *     8192 6963199 6955008  3.3G 83 Linux


Command (m for help): d

Selected partition 1

Partition 1 has been deleted.


3. 할당되지 않은 부분을 파티션을 추가하여 잡아준다.


Command (m for help): n

Partition type

   p   primary (1 primary, 0 extended, 3 free)

   e   extended (container for logical partitions)

Select (default p): p

Partition number (1-4, default 1): 2

First sector (2048-31244287, default 2048): 6963200

Last sector, +sectors or +size{K,M,G,T,P} (2048-31244287, default 31244287): 31244287


Created a new partition 1 of type 'Primary' and of size 11.1 GiB.


Command (m for help): w

The partition table has been altered.

Calling ioctl() to re-read partition table.

Re-reading the partition table failed.: 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).


4. 파티션에 파일시스템을 만들어주어야한다.


root@beaglebone:/home/debian# mkfs -t ext4 /dev/mmcblk0p2

(생략)


root@beaglebone:/home/debian# file -s /dev/mmcblk0p2

/dev/mmcblk0p2: Linux rev 1.0 ext4 filesystem data, UUID=affccd20-4f82-4d29-b5fc-83374ed920a0 (extents) (64bit) (large files) (huge files)



5. 만든 파일시스템을 마운트한다.


1) 실행 시점에서만 마운트

root@beaglebone:/home/debian# mount /dev/mmcblk0p2 /storage/

(/storage에 마운트)


2) 부팅 시, 자동 마운트(파일 시스템 테이블에서 추가)

root@beaglebone:/home/debian# vi /etc/fstab


-----------------------------------------------------------------------------------

추가 : 2017-12-14

Beagleboard:Expanding File System Partition On A microSD

This is a tutorial on how to expand the space used by the file system on an external micro SD card on your BeagleBone Black. This tutorial will work with any of the Linux operating systems mentioned on Ubuntu On BeagleBoard Black or Debian On BeagleBoard Black that boot from a micro SD card. The images on those pages are set up for 1-4 GB micro SD cards. If you are using a larger micro SD card you can re-partition it to have more space available for the file system. You can expand the file system's partition to any unused space on your micro SD card. This tutorial uses fdisk and resize2fsso if the distribution you are using supports those you should be able to follow along.

Expanding the File System Partition

These steps assume you are booting from a micro SD card with some sort of extra unused space. You will need to access the command line of whatever operating system you are using. The easiest way to do this is to connect to your BeagleBone Black with a display, mouse, and keyboard. You may also try connecting over serial (described here) or SSH although that may be different depending on your version of Linux.

Just to be completely clear, you are executing these steps from the terminal on your BeagleBone Black in the OS you are using.

Note: For the following command line instructions, do not type the '#', that is only to indicate that it is a command to enter.

From the command line of your Linux OS on your BeagleBone Black, become super user. The password will depend on your version of Linux (see the page that described how to install your version of Linux).

# sudo -i
  • You don't have to become super user. If you don't want to, just put 'sudo' at the beginning of all your commands.

Check available volumes on the BeagleBone Black

# ls /dev/mmcblk*

Depending on what version of Linux you are running it should look something like this:

brw-rw---- 1 root disk 179,  0 Oct  2 23:09 /dev/mmcblk0
brw-rw---- 1 root disk 179,  1 Oct  2 23:09 /dev/mmcblk0p1
brw-rw---- 1 root disk 179,  8 Oct  2 23:09 /dev/mmcblk1
brw-rw---- 1 root disk 179, 24 Oct  2 23:09 /dev/mmcblk1boot0
brw-rw---- 1 root disk 179, 32 Oct  2 23:09 /dev/mmcblk1boot1
brw-rw---- 1 root disk 179,  9 Oct  2 23:09 /dev/mmcblk1p1

This shows the μSD card (mmcblk0) and eMMC (mmcblk1), each having one partition. (You can ignore the special "boot0/1" partitions of the eMMC.) On very old systems there may be two partitions, in which case p2 should be used instead of p1 in the instructions below.

Examine the partitioning on your external SD card:

# fdisk /dev/mmcblk0

Then enter 'p' and you should be shown a print out like this

Command (m for help): p

Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 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
Disklabel type: dos
Disk identifier: 0x18e8111b

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1       8192 7667712 7659521  3.7G 83 Linux

Command (m for help):
  • Note: Some values may be different. An important value to note is the start sector of the Linux partition, 8192 in this case.

Next, enter 'd' to delete the Linux partition. (If you have two partitions it will ask which partition to delete, which should be 2.)

Now it should be recreated: enter 'n' to create a new partition. For the first two questions (partition type and number) just press enter. For the start sector, be absolutely sure to use the same number it had originally. In our example, that would be 8192. For the last sector, you can use whatever you want in case you don't want to use your whole micro SD, but you can just hit enter to use the default (the max size possible).

This is what the interaction looks like in our example:

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 

Using default response p.
Partition number (1-4, default 1): 
First sector (2048-15523839, default 2048): 8192
Last sector, +sectors or +size{K,M,G,T,P} (8192-15523839, default 15523839): 

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

You can enter 'p' again to view the new partition table:

Command (m for help): p
Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 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
Disklabel type: dos
Disk identifier: 0x18e8111b

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192 15523839 15515648  7.4G 83 Linux

Command (m for help):

Note that the size of the partition has increased to that of the whole card, and the start sector is still the same as it was originally.

If you are satisfied with your changes at this point you can enter 'w' to commit to your changes. (If you want to cancel without making any change to the disk, just press <CTRL>+C.)

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.

The warning above will appear if you're repartitioning the disk you've booted from. In that case, reboot your system:

# reboot

Lastly, after your BeagleBone Black reboots, you need to expand the file system. Run the following command (again as root):

# resize2fs /dev/mmcblk0p1

Once this command completes, you're done!

Simplified

The steps in the previous section can be simplified to these essential commands:

  1. sudo su
  2. fdisk /dev/mmcblk0
  3. d
  4. 2
  5. n
  6. p
  7. 2
  8. w
  9. reboot
  10. sudo su (after reboot is complete)
  11. resize2fs /dev/mmcblk0p2


https://elinux.org/Beagleboard:Expanding_File_System_Partition_On_A_microSD

'ARM > BBBW' 카테고리의 다른 글

java FX 개발 환경 구축  (0) 2017.11.28
JAVA 개발 환경 구축  (0) 2017.11.13
3. 모니터 사용하기  (0) 2017.10.16
2. WIFI 사용  (0) 2017.10.15
1-1. eMMC로 부팅하기.  (0) 2017.10.14
Comments