반응형
Gordon Lesti

Mount ext4 USB flash drive to Raspberry Pi

Feb 05, 2016Raspberry Pi

This is just a shameless translation of the german post Raspberry Pi: USB-Stick und USB-Festplatte einbinden from Jan Karres. Jan is also mounting ntfs and fat drives, but I just need ext4 so we will skip his first step. I have also changed some small other things.

Create media directory

Let's create a media directory for the flash drive for our user. The user is for now called gordon and the flash drive gets the name sandisk, cause I have a 128 GB USB flash drive from SanDisk. You should replace both.

sudo mkdir -p /media/gordon/sandisk

Detecting the flash drive

Please make sure that the USB flash drive is plugged and run the following command.

sudo blkid -o list device fs_type label mount point UUID ------------------------------------------------------------------------------------------------------ /dev/mmcblk0p1 vfat boot /boot XXXX-XXXX /dev/mmcblk0p2 ext4 / xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /dev/sda1 ext4 SanDisk (not mounted) xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /dev/mmcblk0 (in use)

The output should look like this. I hope you have identified your drive. If not, just unplug the drive, run the command, plug the drive and run the command again. This should help you to find your flash drive. Important for us is the device column. In my case the SanDisk flash drive has the path /dev/sda1.

Mounting the device

As we now know the path of the device, we can mount it with the following command.

sudo mount -t ext4 -o defaults /dev/sda1 /media/gordon/sandisk

Unmount

We can unmount the device like this.

sudo umount /media/gordon/sandisk

Mount on boot

I want my USB flash drive for my ownCloudinstance. So it would be nice if the device is always available after every boot. Jan has also a solution for this. Now we need the column UUID from the output above. Edit the file /etc/fstab with any editor, for example nano.

sudo nano /etc/fstab

Please add the following line at the end of the file. Make sure to replace the UUID and the path of the mounted device.

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /media/gordon/sandisk ext4 defaults 0

It would be possible to use also /dev/sda1instead of UUID=..., but the UUID makes sure that we are mounting this flash drive and not any other one that could be in the same USB slot. Please keep this in mind if you replace the USB flash drive with an other one.

Setup permissions

After that we will change the owner of this media directory to our user.

sudo chown gordon:gordon -R /media/gordon/

NextPrevious

About

My name is Gordon Lesti. I have a B.Sc. degree in Computer Science.

Tags

Art Audio Bluetooth Books Bootstrap CChrome Conference CSS D3 Debian DockerEmail Firefox Food Fpc Gitlab Grunt InkscapeJava JavaScript LaTeX Linux Magento MathMeetup Mysql ownCloud PDF PHP PrismPython QUnit Raspberry Pi Search SVG TalkTesting Time Series Tool Ubuntu VagrantVideo VirtualBox Windows Wordpress

Archives

Jan 18 Dec 17 Oct 17 Aug 17 Jul 17 May 17Apr 17 Mar 17 Feb 17 Jan 17 Dec 16 Nov 16Oct 16 Sep 16 Aug 16 Jul 16 Jun 16 May 16Mar 16 Feb 16 Jan 16 May 15 Apr 15 Mar 15Feb 15 Jan 15 Dec 14 Nov 14 Sep 14 May 14Apr 14 Feb 14 Jan 14 Sep 13 Aug 13 Jul 13May 13 Apr 13

Links

RSS 2.0

Github

Twitter

This Website is build with Slim, Twig, Grunt,Bootstrap and Prism by Gordon Lesti.

Back to top
반응형

'컴퓨터 & 프로그래밍' 카테고리의 다른 글

테이블  (0) 2018.02.14
리눅스 에디터 선택  (0) 2018.01.29
apache 로그 및 PHP 버전 변경  (0) 2017.12.29
php.ini 위치 확인  (0) 2017.12.29
gz 파일 mysql 실행  (0) 2017.12.29
Posted by 얀웬리
:
BLOG main image
여행 맛집 소소한 일상 선물옵션 투자 재테크 잡다한 이야기 by 얀웬리

공지사항

카테고리

전체분류 보기 (75)
온라인 페이먼트 (3)
FX (Foreign Exchange) (2)
여행 & 맛집 (9)
코인 가상화폐 투자 (1)
해외 사이트 소개 (5)
음악 & 영상 (0)
선물 & 옵션 (2)
컴퓨터 & 프로그래밍 (30)
블로그 관리 (3)
소소한 일상 (3)
잡다한 이야기 (5)
함께 웃어요^^ (1)
건강 (0)
독도 - Dokdo Islands (4)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

Total :
Today : Yesterday :