Tag Archives: Raspberry Pi

Raspberry Pi | apt not working – segmentation fault

If you are experiencing segmentation fault on an apt update like this

peter@rasp1:~ $ sudo apt update
Get:1 http://archive.raspberrypi.org jessie InRelease [22.9 kB]
Get:2 http://mirrordirector.raspbian.org jessie InRelease [14.9 kB]
Get:3 http://mirrordirector.raspbian.org jessie/main armhf Packages [9,536 kB]
Get:4 http://archive.raspberrypi.org jessie/main armhf Packages [171 kB]
E: Method gzip has died unexpectedly!
E: Sub-process gzip received a segmentation fault.
E: Method /usr/lib/apt/methods/gzip did not start correctly

Then it can be resolved by sudo apt-get install –reinstall apt

peter@rasp1:~ $ sudo apt-get install --reinstall apt
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/1,067 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 38419 files and directories currently installed.)
Preparing to unpack .../apt_1.0.9.8.4_armhf.deb ...
Unpacking apt (1.0.9.8.4) over (1.0.9.8.4) ...
Processing triggers for man-db (2.7.5-1~bpo8+1) ...
Setting up apt (1.0.9.8.4) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...

After update and reinstall you will be able to do an sudo apt-update end a sudo apt-upgrade

peter@rasp1:~ $ sudo apt update
Hit http://archive.raspberrypi.org jessie InRelease
Hit http://mirrordirector.raspbian.org jessie InRelease
Get:1 http://mirrordirector.raspbian.org jessie/main armhf Packages [9,536 kB]
Get:2 http://archive.raspberrypi.org jessie/main armhf Packages [171 kB]
Hit http://archive.raspberrypi.org jessie/ui armhf Packages
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB
Ign http://archive.raspberrypi.org jessie/main Translation-en
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB
Get:3 http://mirrordirector.raspbian.org jessie/contrib armhf Packages [43.3 kB]
Ign http://archive.raspberrypi.org jessie/ui Translation-en
Get:4 http://mirrordirector.raspbian.org jessie/non-free armhf Packages [84.2 kB]
Get:5 http://mirrordirector.raspbian.org jessie/rpi armhf Packages [1,356 B]
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en
Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/main Translation-en
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en
Fetched 8,692 kB in 20s (417 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
49 packages can be upgraded. Run 'apt list --upgradable' to see them.

How to Boot Raspberry Pi from USB Hard Drive

Raspberry Pi’s normally boots from a SD/Micro SD card. That also means that your root and home partitions lives on the SD card and there is a lower limit to how big it can be and how fast it is compared to normal Hard Drives and SSD drives. Sometimes it can be better to move all other but the /boot partition to an external Hard Drive.

Here is how to move allready existing partitions to an external drive.

1. First fdisk the drive and create an EXT4 filesystem

FDISK

fdisk /dev/sda
delete existing partitions
create new Primary Linux partition as /dev/sda1
write the system to disk with the command w
exit fdisk 

CREATE FILESYSTEM

mke2fs -t ext4 /dev/sda1

2. Mount the External Harddrive on your Raspberry Pi

sudo su
mount -t ext4 /dev/sda /mnt

3. Install rsync

sudo apt-get install rsync

4. Copy all the files from the microSD card to the external hard drive. By using rsync then all file permissions and ownership are keept intact.

sudo rsync -axv / /mnt

this will take a while to finish.

5. Then we need to modify the Raspberry Pi’s startup file, Your device will look for it on the SDCard in the /boot partition

nano /boot/cmdline.txt

We need to edit two parts of this line. Change the root= to /dev/sda, add rootdelay=5

It should look like this

6. Then we are adding the hard drive entry to “/mnt/etc/fstab” so the root folder in the external hard drive is automatically mounted at boot up.

nano /mnt/etc/fstab

Add this to the end of the file

/dev/sda1       /               ext4    defaults,noatime  0       1

Comment out the line with the SDCard with a # so it look like this

#PARTUUID=c1c4201a-01  /               ext4    defaults,noatime  0       1

After the changes, it should look like this (here is a screenshot from one of my Pi’s)

Reboot your Pi, and it should boot up and run from the external hard drive. One thing to note is that the microSD card needs to be in its slot, as the Pi needs to read the startup file from it before it boots up on the drive you wan’t

It is also possible to boot without the SDcard, but this way is how i prefer it to be done as it is very easy to switch back to the SDcard…just change the

Here is how the result can be with an External 1 TB USB Hard Drive.

Dedicated Raspberry Pi hosting

I have expanded my project with a Dedicated Raspberry Pi 3 hosted in Czechia.

My goal is to move my PHP Server Monitor, DNS and Mail backup services to the new server.

The first year will cost you 110 Euro with a Raspberry Pi 3 + 32 GB SD Card. The following year the cost will be 36 EURO and that makes it a very cheap dedicated server.

Watch the video below about their datacenter….

You will get 100mbit with unlimited bandwidth included.

Read more about this at https://raspberry-hosting.com/en