I have a Raspberry Pi connected to my TV, which I use to read videos stored on an external hard drive.

I have 2 commands that I run everytime the Raspberry Pi reboots:

  • This one, to clear the prompt that shows up on the TV: sudo sh -c "TERM=linux setterm -foreground black -clear all >/dev/tty0"
  • This one, to mount the hard drive: mount -L hard-drive /media/hard-drive

I would like those commands to be automatically ran everytime the Raspberry Pi reboots, so I've added the following to my crontab:

@reboot sh -c "TERM=linux setterm -foreground black -clear all >/dev/tty0"
@reboot mount -L hard-drive /media/hard-drive

However, it doesn't seem to do the trick, because after a reboot, the prompt is still there on the TV, and the drive is not mounted.

What have I done wrong?

  • Put the mount stuff in /etc/fstab. Put the clear screen stuff in ~/.profile. – Dougie Dec 6 '19 at 0:30

To mount the hard drive on boot up you can just add an entry into /etc/fstab, something like:

LABEL=hard-drive     /media/hard-drive    ext4   defaults 0 0

Instead of ext4 you may have to use the filesystem on your hard-drive.

To execute the clear command on startup just create a systemd Unit with:

rpi ~$ sudo systemctl --force --full edit clear-screen.service

In the empty editor insert these statements, save them and quit the editor:

Description=Clear Screen

ExecStart=/bin/sh -c '/usr/bin/setterm -foreground black -clear all >/dev/tty0'


Enable the new service with:

rpi ~$ sudo systemctl enable clear-screen.service
  • Thank you! Works like a charm. Two details I found on my way to making it work: if the device contains an NTFS filesystem, even though df -Th reports it as fuseblk, /etc/ftab still expects ntfs. If the device might not be physically there at boot, then the options defaults should be replaced with defaults,nofail. – David Willis Dec 8 '19 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.